-
Notifications
You must be signed in to change notification settings - Fork 12
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
CP-41972: update xcp to support ack py3 #21
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,7 +186,7 @@ def __init__(self, fn): | |
vendor = None | ||
cls = None | ||
|
||
fh = open(fn) | ||
fh = open(fn, 'r', encoding='UTF-8') | ||
for l in fh: | ||
line = l.rstrip() | ||
if line == '' or line.startswith('#'): | ||
|
@@ -260,7 +260,7 @@ def __init__(self): | |
stdout = subprocess.PIPE) | ||
for l in cmd.stdout: | ||
line = l.rstrip() | ||
el = [x for x in line.replace('"', '').split() if not x.startswith('-')] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @alexhimmel because Popen() changes it's return value to bytes, this is a needed fix But, the current testsuite also needs to be update to reflect this behavior, otherwise it would fail to pass for Python3. I've done the needed testsuite updates in my own fork, see below. Thus, this change must be applied with the testsuite fix to have working CI/PR checks. Likewise, the tests for biosdevname have to be fixed and cmd.py is also missing the same fixes. I've done all this as well. You can review, checkout and test the needed fixes here: xenserver-next#2 Please check if the lated branch works for you: PS: We have to fix the Python3 testsuite for #17 before we can merge these fixes, but it's next on my TODO, and you can test the new branch https://github.com/xenserver-next/python-libs/tree/testsuite-driven-py3+Popen fixes all Python3 issues you detec in python-lib. Best Regards, Bernhard There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @bernhardkaindl There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fixes issues which the changes in this PR adressed are now merged to master. Hi @alexhimmel, you could schedule re-testing the ACK XAPI plugin with the new master branch in an upcoming sprint! PS: The Python3 migration is not done yet, there are still many issues (or at least untested cases) which need testing and likely fixing. For example the github action summay page is currently still showing pytype errors in xcp/accessor.py and xcp/repository.py. If the ACK plugin uses such modules or you run into any other error, please open an issue here to report the problem, thanks! |
||
el = [x for x in line.decode().replace('"', '').split() if not x.startswith('-')] | ||
self.devs[el[0]] = {'id': el[0], | ||
'class': el[1][:2], | ||
'subclass': el[1][2:], | ||
|
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.
The purpose of this change is not clear, the reason is:
All of these work just fine and produce the same output:
But
encoding=
is not supported by Python2:Also, it does not change anything because UTF-8 is already the default encoding, at least on XenServer 8.3.0 with Python3.6 installed:
If you use a different Python enviromnent for testing, and get different results, switch it to UTF-8 by default as well.
Therefore, revert this change:
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.
Hi @bernhardkaindl
Got error when try the nwe branch with
fh = open(fn)
Can fix this issue when specify the correct codec when opening the file or when calling the decode method e.g.
fh = open(fn, 'r', encoding='UTF-8')
or somewhere decode thestdout
withstdout.decode('UTF-8')