-
Notifications
You must be signed in to change notification settings - Fork 1.6k
donate-cpu-server.py: Upgrade to work with Python 3 (drop Python 2 support) #2292
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
Conversation
|
I have thoroughly tested the server locally, but I appreciate any reviews, tests and so on. |
|
Todo: Ignore donate-cpu-server.py for pylint (Python 2) analysis. It will fail since it is Python 3 only. EDIT: This is done now |
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.
Need to update tools/test/start_donate_cpu_server_test_local.sh to use python3 instead of python?
c694964 to
34240d3
Compare
45d5f70 to
99c5826
Compare
tools/donate-cpu-server.py
Outdated
| return datetime.datetime.now().strftime('%Y-%m-%d %H:%M') | ||
|
|
||
|
|
||
| def dateTimeFromStr(datestr): |
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.
How about def dateTimeFromStr(datestr: str):
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.
AFAIK this would require at least Python 3.5. I am not sure if everyone who develops on this script has such a recent version. Personally I like these typeinfo hints.
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.
AFAIK this would require at least Python 3.5. I am not sure if everyone who develops on this script has such a recent version. Personally I like these typeinfo hints.
That is not quite right. The function annotations itself are available since Python 3.0, see https://www.python.org/dev/peps/pep-3107/.
Type hints (see https://www.python.org/dev/peps/pep-0484/) are available since Python 3.5.
So it looks like it is acceptable to add function annotations like you suggested (and I also like better).
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.
I have added Python 3.0 function annotations instead of the comments with type hints now.
For the client script, which should be Python 2 compatible, we could use the comments with type hints. What do you think?
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.
yes in the client script the comments are fine.
The following commands were used for these changes: futurize -1 -w donate-cpu-server.py 2to3 -w donate-cpu-server.py
Manually fixed the Unicode issues. Received data is decoded, sent data is encoded.
This enables better static analysis and suggestions in an IDE.
donate-cpu-server.py is only Python 3 compatible, so it must be ignored for pylint verification under Python 2. All Python scripts that were verified with pylint under Python 2 are now also verified with pylint under Python 3.
Since the server script is executable now and has a shebang it can be directly executed.
99c5826 to
62205e7
Compare
danmar
left a comment
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.
Thanks! Feel free to merge this
No description provided.