MCPcopy
hub / github.com/yougov/mongo-connector / download_setuptools

Function download_setuptools

ez_setup.py:139–173  ·  view source on GitHub ↗

Download setuptools from a specified location and return its filename `version` should be a valid setuptools 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

137
138
139def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
140 to_dir=os.curdir, delay=15):
141 """Download setuptools from a specified location and return its filename
142
143 `version` should be a valid setuptools version number that is available
144 as an egg for download under the `download_base` URL (which should end
145 with a '/'). `to_dir` is the directory where the egg will be downloaded.
146 `delay` is the number of seconds to pause before an actual download
147 attempt.
148 """
149 # making sure we use the absolute path
150 to_dir = os.path.abspath(to_dir)
151 try:
152 from urllib.request import urlopen
153 except ImportError:
154 from urllib2 import urlopen
155 tgz_name = "setuptools-%s.tar.gz" % version
156 url = download_base + tgz_name
157 saveto = os.path.join(to_dir, tgz_name)
158 src = dst = None
159 if not os.path.exists(saveto): # Avoid repeated downloads
160 try:
161 log.warn("Downloading %s", url)
162 src = urlopen(url)
163 # Read/write all in one block, so we don't create a corrupt file
164 # if the download is interrupted.
165 data = src.read()
166 dst = open(saveto, "wb")
167 dst.write(data)
168 finally:
169 if src:
170 src.close()
171 if dst:
172 dst.close()
173 return os.path.realpath(saveto)
174
175
176def _extractall(self, path=".", members=None):

Callers 2

_do_downloadFunction · 0.85
mainFunction · 0.85

Calls 2

joinMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected