Skip to content

Commit

Permalink
Properly handle the case of missing CCR dependency.
Browse files Browse the repository at this point in the history
The new Chakra website does not return an HTTP error, but some
error page, which chaser tries to interpret as the package tarfile,
raising an exception. Catch the exception and print a more helpful
error message.
  • Loading branch information
shainer committed Aug 4, 2017
1 parent a4fc14e commit 75657f7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions chaser/chaser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@ def get_source_files(args, workingdir=None):
os.mkdir(workingdir)

for pkgname in pkgnames:
print('Downloading %s' % pkgname)
r = requests.get(ccr.pkg_url(pkgname))
r.raise_for_status()
tar = tarfile.open(mode='r', fileobj=io.BytesIO(r.content))
tar.extractall(workingdir)

try:
tar = tarfile.open(mode='r', fileobj=io.BytesIO(r.content))
tar.extractall(workingdir)
except tarfile.ReadError as re:
print('Unable to open the tar file. Either the package does not '
'exist in CCR or it is malformed: %s' % str(re))


def recurse_depends(pkgname, workingdir=None, graph=None):
"""Build a dependency graph"""
Expand Down

0 comments on commit 75657f7

Please sign in to comment.