Skip to content

Commit e170b71

Browse files
Removal of superfluous test and code. Variable rename.
1 parent 22630b3 commit e170b71

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

pythonanywhere/api.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,13 @@ def get_log_info(self):
227227
response_text=response.text,
228228
)
229229
)
230-
if re.match(r"\[.*\]", response.text):
231-
file_list = eval(response.text)
232-
else:
233-
raise Exception(
234-
"GET log files info via API failed, got {text} instead of list of files".format(text=response.text))
230+
file_list = response.json()
235231
log_types = ["access", "error", "server"]
236232
logs = {"access": [], "error": [], "server": []}
237233
log_prefix = "/var/log/{domain}.".format(domain=self.domain)
238-
for file in file_list:
239-
if type(file) == str and file.startswith(log_prefix):
240-
log = file[len(log_prefix):].split(".")
234+
for file_name in file_list:
235+
if type(file_name) == str and file_name.startswith(log_prefix):
236+
log = file_name[len(log_prefix):].split(".")
241237
if log[0] in log_types:
242238
log_type = log[0]
243239
if log[-1] == "log":

tests/test_api.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,3 @@ def test_raises_if_get_does_not_20x(self, api_responses, api_token):
401401

402402
assert "GET log files info via API failed" in str(e.value)
403403
assert "nope" in str(e.value)
404-
405-
def test_raises_if_response_text_not_list(self, api_responses, api_token):
406-
expected_url = get_api_endpoint().format(
407-
username=getpass.getuser(), flavor="files") + "tree/?path=/var/log/"
408-
api_responses.add(responses.GET, expected_url, status=200, body="print('Behold malicious code')")
409-
410-
with pytest.raises(Exception) as e:
411-
Webapp("mydomain.com").get_log_info()
412-
413-
assert "GET log files info via API failed, got print('Behold malicious code')" in str(e.value)

0 commit comments

Comments
 (0)