Skip to content
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

Closed
wants to merge 2 commits into from
Closed

transition to python 3 #333

wants to merge 2 commits into from

Conversation

liewegas
Copy link
Member

No description provided.

Signed-off-by: Sage Weil <sage@redhat.com>
Signed-off-by: Sage Weil <sage@redhat.com>
@liewegas
Copy link
Member Author

This doesn't work.. I have no idea what i'm doing

@liewegas liewegas requested a review from kshtsk December 16, 2019 00:08
@@ -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
Copy link

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
Copy link

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
Copy link

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)
Copy link

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)
Copy link

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
Copy link

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)
Copy link

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)
Copy link

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
Copy link

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?

@tchaikov
Copy link
Contributor

closing. as i think #336 is a better fix.

@tchaikov tchaikov closed this Dec 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants