Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update encoding process #820

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions jenkinsapi/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def get_timestamp(self):
*time.gmtime(self._data['timestamp'] / 1000.0)[:6])
return pytz.utc.localize(naive_timestamp)

def get_console(self):
def get_console(self, encoding='ISO-8859-1'):
"""
Return the current state of the text console.
"""
Expand All @@ -499,11 +499,11 @@ def get_console(self):
if isinstance(content, str):
return content
elif isinstance(content, bytes):
return content.decode('ISO-8859-1')
return content.decode(encoding)
else:
raise JenkinsAPIException('Unknown content type for console')

def stream_logs(self, interval=0):
def stream_logs(self, interval=0, encoding='ISO-8859-1'):
"""
Return generator which streams parts of text console.
"""
Expand All @@ -517,7 +517,7 @@ def stream_logs(self, interval=0):
if isinstance(content, str):
yield content
elif isinstance(content, bytes):
yield content.decode('ISO-8859-1')
yield content.decode(encoding)
else:
raise JenkinsAPIException('Unknown content type for console')
size = resp.headers['X-Text-Size']
Expand Down