Skip to content

Python 3 compatibility #1931

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

Merged
merged 1 commit into from
Apr 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions tools/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Written by Ivan Grokhotkov, 2015.
#
from __future__ import print_function
import urllib
import os
import shutil
import errno
Expand All @@ -16,6 +15,11 @@
import tarfile
import zipfile
import re
if sys.version_info[0] == 3:
from urllib.request import urlretrieve
else:
# Not Python 3 - today, it is most likely to be Python 2
from urllib import urlretrieve

dist_dir = 'dist/'

Expand Down Expand Up @@ -54,7 +58,7 @@ def unpack(filename, destination):
raise NotImplementedError('Unsupported archive type')

# a little trick to rename tool directories so they don't contain version number
rename_to = re.match(r'^([a-z][^\-]*\-*)+', dirname).group(0).encode('ascii').strip('-')
rename_to = re.match(r'^([a-z][^\-]*\-*)+', dirname).group(0).strip('-')
if rename_to != dirname:
print('Renaming {0} to {1}'.format(dirname, rename_to))
if os.path.isdir(rename_to):
Expand All @@ -68,7 +72,7 @@ def get_tool(tool):
real_hash = tool['checksum'].split(':')[1]
if not os.path.isfile(local_path):
print('Downloading ' + archive_name);
urllib.urlretrieve(url, local_path, report_progress)
urlretrieve(url, local_path, report_progress)
sys.stdout.write("\rDone\n")
sys.stdout.flush()
else:
Expand Down