Skip to content

Commit

Permalink
Change to use curl for downloading files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dag Sverre Seljebotn committed Dec 9, 2012
1 parent 9878179 commit 02b8ed8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hashdist/source_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ def _download_and_hash(self, url):
temp_file, digest
"""
# Make request
req = urllib2.urlopen(url)
sys.stderr.write('Downloading %s...\n' % url)
curl = subprocess.Popen(['curl', url], stdout=subprocess.PIPE,
stdin=subprocess.PIPE)
curl.stdin.close()

# Download file to a temporary file within self.packs_path, while hashing
# it
Expand All @@ -220,7 +223,7 @@ def _download_and_hash(self, url):
f = os.fdopen(temp_fd, 'wb')
try:
while True:
chunk = req.read(self.chunk_size)
chunk = curl.stdout.read(self.chunk_size)
if not chunk: break
hasher.update(chunk)
f.write(chunk)
Expand Down

0 comments on commit 02b8ed8

Please sign in to comment.