Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion google/datalab/storage/commands/_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ def _gcs_view(args, _):
contents = _get_object_contents(args['object'])
if not isinstance(contents, basestring):
contents = str(contents)
lines = contents.split('\n')
elif isinstance(contents, bytes):
contents = str(contents, encoding='UTF-8')
lines = contents.splitlines()
head_count = args['head']
tail_count = args['tail']
if len(lines) > head_count + tail_count:
Expand Down
5 changes: 4 additions & 1 deletion google/datalab/utils/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def __init__(self, status, content):
self.message = 'HTTP request failed'
# Try extract a message from the body; swallow possible resulting ValueErrors and KeyErrors.
try:
error = json.loads(content)['error']
if type(content) == str:
error = json.loads(content)['error']
else:
error = json.loads(str(content, encoding='UTF-8'))['error']
if 'errors' in error:
error = error['errors'][0]
self.message += ': ' + error['message']
Expand Down