-
Notifications
You must be signed in to change notification settings - Fork 284
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
transition to python 3 #333
Conversation
Signed-off-by: Sage Weil <sage@redhat.com>
This doesn't work.. I have no idea what i'm doing |
@@ -34,18 +34,18 @@ elif [ -f /etc/redhat-release ]; then | |||
fi | |||
fi | |||
|
|||
virtualenv --no-site-packages --distribute virtualenv | |||
virtualenv --no-site-packages --distribute virtualenv -p /usr/bin/python3 |
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.
It is enough to provide -p python3
.
|
||
./virtualenv/bin/pip install -r requirements.txt | ||
|
||
# forbid setuptools from using the network because it'll try to use | ||
# easy_install, and we really wanted pip; next line will fail if pip | ||
# requirements.txt does not match setup.py requirements -- sucky but | ||
# good enough for now | ||
./virtualenv/bin/python setup.py develop | ||
./virtualenv/bin/python3 setup.py develop |
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.
there is no need to provide python3
here, since ./virtualenv/bin/python
is already pointed to python3 created in with virtualenv
.
@@ -1,4 +1,4 @@ | |||
#!/usr/bin/python | |||
#!/usr/bin/python3 |
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.
If this code is going to be run in the venv creates as about, there is no sense to use shebang at all.
@@ -43,7 +43,7 @@ def upload_objects(bucket, files, seed): | |||
name_generator = realistic.names(15, 4, seed=seed) | |||
|
|||
for fp in files: | |||
print >> sys.stderr, 'sending file with size %dB' % fp.size | |||
sys.stderr.write('sending file with size %dB\n' % fp.size) |
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.
Here and after for py2/py3 compatibility I guess you better use print from future package, like this:
from __future__ import print_function
.
.
.
print('sending file with size %dB' % fp.size, file=sys.stderr)
@@ -94,18 +94,18 @@ def _main(): | |||
|
|||
bucket.set_acl('public-read') | |||
keys = [] | |||
print >> OUTFILE, 'bucket: %s' % bucket.name | |||
print >> sys.stderr, 'setup complete, generating files' | |||
OUTFILE.write('bucket: %s\n' % bucket.name) |
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.
See the comment above.
@@ -227,7 +227,7 @@ def files(mean, stddev, seed=None): | |||
re-download the object and place the contents into a file called | |||
``foo``, the following should print two identical lines: | |||
|
|||
python -c 'import sys, hashlib; data=sys.stdin.read(); print hashlib.md5(data[:-16]).hexdigest(); print "".join("%02x" % ord(c) for c in data[-16:])' <foo | |||
python3 -c 'import sys, hashlib; data=sys.stdin.read(); print hashlib.md5(data[:-16]).hexdigest(); print "".join("%02x" % ord(c) for c in data[-16:])' <foo |
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.
This code is not python3 compatible.
@@ -43,7 +43,7 @@ def upload_objects(bucket, files, seed): | |||
name_generator = realistic.names(15, 4, seed=seed) | |||
|
|||
for fp in files: | |||
print >> sys.stderr, 'sending file with size %dB' % fp.size | |||
sys.stderr.write('sending file with size %dB\n' % fp.size) |
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.
See the comment regarding future print.
@@ -57,7 +57,7 @@ def reader(bucket, worker_id, file_names, queue, rand): | |||
traceback=traceback.format_exc(), | |||
), | |||
) | |||
print "ERROR:", m | |||
print("ERROR:", m) |
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.
This requires future python feature enabled in order it prints the same way as in py2
@@ -227,7 +227,7 @@ def files(mean, stddev, seed=None): | |||
re-download the object and place the contents into a file called | |||
``foo``, the following should print two identical lines: | |||
|
|||
python -c 'import sys, hashlib; data=sys.stdin.read(); print hashlib.md5(data[:-16]).hexdigest(); print "".join("%02x" % ord(c) for c in data[-16:])' <foo | |||
python3 -c 'import sys, hashlib; data=sys.stdin.read(); print hashlib.md5(data[:-16]).hexdigest(); print "".join("%02x" % ord(c) for c in data[-16:])' <foo |
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.
Looks like dejavu, is it a code duplication here?
closing. as i think #336 is a better fix. |
No description provided.