4
4
# Written by Ivan Grokhotkov, 2015.
5
5
#
6
6
from __future__ import print_function
7
- import urllib
8
7
import os
9
8
import shutil
10
9
import errno
16
15
import tarfile
17
16
import zipfile
18
17
import re
18
+ if sys .version_info [0 ] == 3 :
19
+ from urllib .request import urlretrieve
20
+ else :
21
+ # Not Python 3 - today, it is most likely to be Python 2
22
+ from urllib import urlretrieve
19
23
20
24
dist_dir = 'dist/'
21
25
@@ -54,7 +58,7 @@ def unpack(filename, destination):
54
58
raise NotImplementedError ('Unsupported archive type' )
55
59
56
60
# a little trick to rename tool directories so they don't contain version number
57
- rename_to = re .match (r'^([a-z][^\-]*\-*)+' , dirname ).group (0 ).encode ( 'ascii' ). strip ('-' )
61
+ rename_to = re .match (r'^([a-z][^\-]*\-*)+' , dirname ).group (0 ).strip ('-' )
58
62
if rename_to != dirname :
59
63
print ('Renaming {0} to {1}' .format (dirname , rename_to ))
60
64
if os .path .isdir (rename_to ):
@@ -68,7 +72,7 @@ def get_tool(tool):
68
72
real_hash = tool ['checksum' ].split (':' )[1 ]
69
73
if not os .path .isfile (local_path ):
70
74
print ('Downloading ' + archive_name );
71
- urllib . urlretrieve (url , local_path , report_progress )
75
+ urlretrieve (url , local_path , report_progress )
72
76
sys .stdout .write ("\r Done\n " )
73
77
sys .stdout .flush ()
74
78
else :
0 commit comments