MCPcopy Index your code
hub / github.com/davispuh/MySQL-for-Python-3 / download_setuptools

Function download_setuptools

distribute_setup.py:171–205  ·  view source on GitHub ↗

Download distribute from a specified location and return its filename `version` should be a valid distribute version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded.

(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
                        to_dir=os.curdir, delay=15)

Source from the content-addressed store, hash-verified

169
170
171def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
172 to_dir=os.curdir, delay=15):
173 """Download distribute from a specified location and return its filename
174
175 `version` should be a valid distribute version number that is available
176 as an egg for download under the `download_base` URL (which should end
177 with a '/'). `to_dir` is the directory where the egg will be downloaded.
178 `delay` is the number of seconds to pause before an actual download
179 attempt.
180 """
181 # making sure we use the absolute path
182 to_dir = os.path.abspath(to_dir)
183 try:
184 from urllib.request import urlopen
185 except ImportError:
186 from urllib2 import urlopen
187 tgz_name = "distribute-%s.tar.gz" % version
188 url = download_base + tgz_name
189 saveto = os.path.join(to_dir, tgz_name)
190 src = dst = None
191 if not os.path.exists(saveto): # Avoid repeated downloads
192 try:
193 log.warn("Downloading %s", url)
194 src = urlopen(url)
195 # Read/write all in one block, so we don't create a corrupt file
196 # if the download is interrupted.
197 data = src.read()
198 dst = open(saveto, "wb")
199 dst.write(data)
200 finally:
201 if src:
202 src.close()
203 if dst:
204 dst.close()
205 return os.path.realpath(saveto)
206
207
208def _no_sandbox(function):

Callers 2

_do_downloadFunction · 0.85
mainFunction · 0.85

Calls 1

closeMethod · 0.80

Tested by

no test coverage detected