-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[system-health] Convert to Python 3 #5886
Conversation
@Junchao-Mellanox: Please review. |
See https://github.com/Azure/sonic-buildimage/blob/6c362a08e72e14da8880586f089d4860e786947c/src/system-health/scripts/healthd#L71, system health depends on platform API to set the chassis LED. It means that we need the platform API to support python3 first. |
@Junchao-Mellanox: I believe currently only Mellanox supports the system-health daemon. I will set this back to draft until Mellanox has a Python 3 sonic-platform package installed. Please keep me posted. |
Sure. |
a preliminary check, seems that we still need some change in this here https://github.com/Azure/sonic-buildimage/blob/master/src/system-health/health_checker/utils.py#L11 |
in these two lines need decode the 'output' before using : output.decode('utf-8') |
Thanks for catching this! Rather than decoding, I added a EDIT: I replaced Also, note that I found that the Python files all had DOS line endings, so I changed them all to UNIX, which is why the diff is now much larger. |
This comment has been minimized.
This comment has been minimized.
@keboliu, @Junchao-Mellanox: Are we good to merge this PR now? If so, please review again. |
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.
LGTM
Pass universal_newlines=True parameter to subprocess.Popen(); no longer use .encode('utf-8') on resulting stdout. This was missed in #5886 Note: I would prefer to use text=True instead of universal_newlines=True, as the former is an alias only available in Python 3 and is more understandable than the latter. However, Even though the setup.py file for this package only specifies Python 3, the LGTM tool finds other Python 2 code in the repo and validates the code as Python 2 code and alerts that text=True is an invalid parameter. Will stick with universal_newlines=True for now. Once all Python code in the repo has been converted to Python 3, I will change all universal_newlines=True to text=True.
Pass universal_newlines=True parameter to subprocess.Popen(); no longer use .encode('utf-8') on resulting stdout. This was missed in #5886 Note: I would prefer to use text=True instead of universal_newlines=True, as the former is an alias only available in Python 3 and is more understandable than the latter. However, Even though the setup.py file for this package only specifies Python 3, the LGTM tool finds other Python 2 code in the repo and validates the code as Python 2 code and alerts that text=True is an invalid parameter. Will stick with universal_newlines=True for now. Once all Python code in the repo has been converted to Python 3, I will change all universal_newlines=True to text=True.
- Why I did it
As part of moving all SONiC code from Python 2 (no longer supported) to Python 3.
- How I did it
- How to verify it
Ensure system-health package builds, installs and works properly
- Which release branch to backport (provide reason below if selected)
Fixes #6104