diff options
Diffstat (limited to 'sources.py')
-rw-r--r-- | sources.py | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -25,6 +25,7 @@ import subprocess import tempfile import getpass + def checksum(path, sum_type, sum_expected): algorithm = getattr(hashlib, sum_type) try: @@ -34,7 +35,7 @@ def checksum(path, sum_type, sum_expected): actual = algorithm(content).hexdigest() return actual == sum_expected - except: + except Exception: return False @@ -48,6 +49,7 @@ class FileSource: # not sure if this is safe enough subprocess.check_call(["tar", "xf", self.path, "-C", dest]) + class DockerSource: def __init__(self, url, username, password, insecure): self.registry = url.netloc @@ -75,8 +77,8 @@ class DockerSource: if self.username: if not self.password: self.password = getpass.getpass() - cmd.append('--src-creds=%s:%s' % (self.username, self.password)) - + cmd.append('--src-creds=%s:%s' % (self.username, + self.password)) subprocess.check_call(cmd) @@ -92,12 +94,12 @@ class DockerSource: # Verify the checksum if not checksum(layer_file, sum_type, sum_value): - raise Exception("Digest not matching: %s" % layer['digest']) + raise Exception("Digest not matching: " + layer['digest']) # untar layer into dest subprocess.check_call(["tar", "xf", layer_file, "-C", dest]) - except: + except Exception: shutil.rmtree(tmpDest) raise |