diff options
author | Radostin Stoyanov <rstoyanov1@gmail.com> | 2017-06-06 17:41:45 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cbosdonnat@suse.com> | 2017-06-07 09:44:12 +0200 |
commit | 4c45f1771bd1ba655294ff325553fb5eba770f65 (patch) | |
tree | c02332bbf4eee185a8b0f3bd67f4ef258bfb20c4 /sources.py | |
parent | 0208ee3a87ea3bc2be408420b1efa8c223885cb4 (diff) | |
download | virt-bootstrap.git-4c45f1771bd1ba655294ff325553fb5eba770f65.tar.gz virt-bootstrap.git-4c45f1771bd1ba655294ff325553fb5eba770f65.tar.xz virt-bootstrap.git-4c45f1771bd1ba655294ff325553fb5eba770f65.zip |
Improve code fomatting
Follow PEP8 using pycodestyle
https://pypi.python.org/pypi/pycodestyle/
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 |