summaryrefslogtreecommitdiffstats
path: root/sources.py
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2017-06-06 17:41:45 +0100
committerCédric Bosdonnat <cbosdonnat@suse.com>2017-06-07 09:44:12 +0200
commit4c45f1771bd1ba655294ff325553fb5eba770f65 (patch)
treec02332bbf4eee185a8b0f3bd67f4ef258bfb20c4 /sources.py
parent0208ee3a87ea3bc2be408420b1efa8c223885cb4 (diff)
downloadvirt-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.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/sources.py b/sources.py
index a799e09..2ac31a8 100644
--- a/sources.py
+++ b/sources.py
@@ -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