in lib/muchos/config/base.py [0:0]
def checksum_ver(self, software, version):
if not isfile(self.checksums_path):
exit(
"ERROR - A checksums file does not exist at {}".format(
self.hosts_path
)
)
if "SNAPSHOT" in version:
return ""
if not self.checksums_d:
self.checksums_d = {}
with open(self.checksums_path) as f:
for line in f:
line = line.strip()
if line.startswith("#") or not line:
continue
args = line.split(":")
if len(args) == 3:
inferred_algo = self.infer_hash_algo(args[2])
if inferred_algo is not None:
self.checksums_d[
"{0}:{1}".format(args[0], args[1])
] = "{0}:{1}".format(
self.infer_hash_algo(args[2]), args[2]
)
else:
exit(
"ERROR - Bad line {} in checksums {}".format(
line, self.checksums_path
)
)
elif len(args) == 4:
if args[2] not in HASHLEN_ALGO_MAP.values():
exit(
"ERROR - Unsupported hash algorithm {} "
"in checksums {}".format(
line, self.checksums_path
)
)
self.checksums_d[
"{0}:{1}".format(args[0], args[1])
] = "{0}:{1}".format(args[2], args[3])
else:
exit(
"ERROR - Bad line {} in checksums {}".format(
line, self.checksums_path
)
)
key = "{0}:{1}".format(software, version)
if key not in self.checksums_d:
exit(
"ERROR - Failed to find checksums for {} {} in {}".format(
software, version, self.checksums_path
)
)
return self.checksums_d[key]