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
Removed "encode" on color in get_job_status #66585
Removed "encode" on color in get_job_status #66585
Conversation
In Python3 (tested in 3.8.1), variable.encode('utf-8') returns as a byte string versus just a string in Python2 (tested in 2.7.17). Removed encode method on return of get_job_status when color exists and wrapped in str() for good measure.
@@ -216,7 +216,7 @@ def get_job_status(self): | |||
if "color" not in response: | |||
return self.EXCL_STATE | |||
else: | |||
return response['color'].encode('utf-8') | |||
return str(response['color']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please use to_native
or to_text
instead? You can find the function here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Akasurde Thank you very much for the feedback! Changed to to_native
.
cc @jtyr Could you please review this? Thanks in advance. |
It LGTM but the author of the module (@sermilrod) should review it. |
I cannot merge it myself but it also LGTM 👍 |
* Removed "encode" on color in get_job_status In Python3 (tested in 3.8.1), variable.encode('utf-8') returns as a byte string versus just a string in Python2 (tested in 2.7.17). Removed encode method on return of get_job_status when color exists and wrapped in str() for good measure. * Swap str() for to_native() per feedback
SUMMARY
Bug in jenkins_job module with Python3 - Could only disable a job, but never enable
Removed
.encode('utf-8')
fromresponse['color']
on return of get_job_status in web_infrastructure/jenkins_job.py and wrapped it in str() for good measure. Fixes enabling/disabling Jenkins Job when using Python3 (tested in 3.8.1).In Python3 (tested in 3.8.1),
variable.encode('utf-8')
returns as a byte string; returns a string in Python2 (tested in 2.7.17).Sample Python Test
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
Expectation
Using Python3, be able to enable and disable Jenkins Job using boolean on "enabled" parameter idempotently.
Reality
Using Python3:
Reproducing:
STEP 1: Start Docker Container for Jenkins and get PASSWORD from log
STEP 2: Upload Jenkins Job to container (Copy XML below to a file named "config.xml")
config.xml (save as "config.xml" for use with curl)
STEP 3: Run Playbook
jenkins_job_update.yml