|
16 | 16 | import sys
|
17 | 17 |
|
18 | 18 | import os
|
| 19 | +import shutil |
19 | 20 | from setuptools import Command
|
20 | 21 | from setuptools import setup
|
21 | 22 | from setuptools.command.install import install
|
22 | 23 |
|
23 | 24 | if sys.version_info[0] >= 3:
|
24 | 25 | # Python 3
|
25 |
| - from urllib.request import urlretrieve |
| 26 | + from urllib.request import urlopen |
26 | 27 | else:
|
27 | 28 | # Python 2
|
28 |
| - from urllib import urlretrieve |
| 29 | + from urllib2 import urlopen |
29 | 30 |
|
30 | 31 | #
|
31 | 32 | # This script modifies the basic setuptools by adding some functionality to the standard
|
@@ -113,7 +114,7 @@ def download_and_check(self):
|
113 | 114 | self.on_completion()
|
114 | 115 | missing_jars = self.missing_jars()
|
115 | 116 | if len(missing_jars) > 0:
|
116 |
| - print(self.warning_string(missing_jars)) |
| 117 | + raise RuntimeError(self.warning_string(missing_jars)) |
117 | 118 |
|
118 | 119 | def package_destination(self, artifcat_id, version):
|
119 | 120 | return '{artifcat_id}-{version}.jar'.format(artifcat_id=artifcat_id, version=version)
|
@@ -141,10 +142,12 @@ def download_file(self, url, dest):
|
141 | 142 | """
|
142 | 143 | print('Attempting to retrieve remote jar {url}'.format(url=url))
|
143 | 144 | try:
|
144 |
| - urlretrieve(url, dest) |
| 145 | + response = urlopen(url) |
| 146 | + with open(dest, 'wb') as dest_file: |
| 147 | + shutil.copyfileobj(response, dest_file) |
145 | 148 | print('Saving {url} -> {dest}'.format(url=url, dest=dest))
|
146 |
| - except: |
147 |
| - print('Failed to retrieve {url}'.format(url=url)) |
| 149 | + except Exception as e: |
| 150 | + print('Failed to retrieve {url}: {e}'.format(url=url, e=e)) |
148 | 151 | return
|
149 | 152 |
|
150 | 153 | def download_files(self):
|
|
0 commit comments