Skip to content

Commit 47d04e8

Browse files
committed
fix(logger): requests object returns bytes from logger, convert to string
1 parent b09101e commit 47d04e8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

rootfs/api/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,16 +486,20 @@ def logs(self, log_lines=str(settings.LOG_LINES)):
486486
except requests.exceptions.RequestException as e:
487487
logger.error("Error accessing deis-logger using url '{}': {}".format(url, e))
488488
raise e
489+
489490
# Handle logs empty or not found
490491
if r.status_code == 204 or r.status_code == 404:
491492
logger.info("GET {} returned a {} status code".format(url, r.status_code))
492493
raise EnvironmentError('Could not locate logs')
494+
493495
# Handle unanticipated status codes
494496
if r.status_code != 200:
495497
logger.error("Error accessing deis-logger: GET {} returned a {} status code"
496498
.format(url, r.status_code))
497499
raise EnvironmentError('Error accessing deis-logger')
498-
return r.content
500+
501+
# cast content to string since it comes as bytes via the requests object
502+
return str(r.content)
499503

500504
def run(self, user, command):
501505
"""Run a one-off command in an ephemeral app container."""

0 commit comments

Comments
 (0)