Refactor try/except blocks
@@ -150,6 +150,10 @@ class ComputePlan:
log.info("Reading {}".format(url))
try:
txt = urlopen(url).read().decode("utf-8")
+ except Exception as ex:
+ log.error(ex)
+ return False
+
datasets = json.loads(txt)
datafound = {}
@@ -171,8 +175,6 @@ class ComputePlan:
log.info("No datasets found")
sys.exit()
self.listfiles = datafound
- except Exception as ex:
- log.error(ex)
return self.listfiles
@@ -186,6 +188,9 @@ class ComputePlan:
log.info("Reading {}".format(url))
try:
txt = urlopen(url).read().decode("utf-8")
+ except Exception as ex:
+ log.error(ex)
+ return False
for nb in yaml.safe_load(txt):
path = nb["name"] + ".ipynb"
@@ -203,8 +208,7 @@ class ComputePlan:
if nb["images"]:
for im in nb["images"]:
self.listfiles[label]["images"].append(im)
- except Exception as ex:
- log.error(ex)
+
def parse_scripts_yaml(self):
if self.release:
@@ -216,6 +220,9 @@ class ComputePlan:
log.info("Reading {}".format(url))
try:
txt = urlopen(url).read().decode("utf-8")
+ except Exception as ex:
+ log.error(ex)
+ return False
for sc in yaml.safe_load(txt):
path = sc["name"] + ".py"
@@ -228,8 +235,6 @@ class ComputePlan:
if sc["datasets"]:
for ds in sc["datasets"]:
self.listfiles[label]["datasets"].append(ds)
- except Exception as ex:
- log.error(ex)
class ParallelDownload:
