Skip to content

Commit

Permalink
More logging when downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed May 15, 2015
1 parent 11f79b5 commit 5fc9d1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions reprounzip/reprounzip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,21 @@ def download_file(url, dest, cachename=None):
except URLError as e:
if cache.exists():
if isinstance(e, HTTPError) and e.code == 304:
logging.info("Cached file %s is up to date", cachename)
logging.info("Download %s: cache is up to date", cachename)
else:
logging.warning("Couldn't download %s: %s", url, e)
logging.warning("Download %s: error downloading %s: %s",
cachename, url, e)
cache.copy(dest)
return
else:
raise

if response is None:
logging.info("Cached file %s is up to date", cachename)
logging.info("Download %s: cache is up to date", cachename)
cache.copy(dest)
return

logging.info("Downloading %s", url)
logging.info("Download %s: downloading %s", cachename, url)
try:
CHUNK_SIZE = 4096
with cache.open('wb') as f:
Expand All @@ -295,5 +296,6 @@ def download_file(url, dest, cachename=None):
except OSError:
pass
raise e
logging.info("Downloaded %s successfully", cachename)

cache.copy(dest)
10 changes: 6 additions & 4 deletions reprozip/reprozip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,21 @@ def download_file(url, dest, cachename=None):
except URLError as e:
if cache.exists():
if isinstance(e, HTTPError) and e.code == 304:
logging.info("Cached file %s is up to date", cachename)
logging.info("Download %s: cache is up to date", cachename)
else:
logging.warning("Couldn't download %s: %s", url, e)
logging.warning("Download %s: error downloading %s: %s",
cachename, url, e)
cache.copy(dest)
return
else:
raise

if response is None:
logging.info("Cached file %s is up to date", cachename)
logging.info("Download %s: cache is up to date", cachename)
cache.copy(dest)
return

logging.info("Downloading %s", url)
logging.info("Download %s: downloading %s", cachename, url)
try:
CHUNK_SIZE = 4096
with cache.open('wb') as f:
Expand All @@ -295,5 +296,6 @@ def download_file(url, dest, cachename=None):
except OSError:
pass
raise e
logging.info("Downloaded %s successfully", cachename)

cache.copy(dest)

0 comments on commit 5fc9d1f

Please sign in to comment.