Adding the stager to checksum any url that spack can handle

This commit is contained in:
Nicolas Richart 2016-01-28 14:22:28 +01:00
parent c2bb00ca2f
commit 5850d8530e

View File

@ -30,8 +30,9 @@
from llnl.util.filesystem import *
import spack.util.crypto
from spack.stage import Stage, FailedDownloadError
description = "Calculate md5 checksums for files."
description = "Calculate md5 checksums for files/urls."
def setup_parser(subparser):
setup_parser.parser = subparser
@ -45,7 +46,18 @@ def md5(parser, args):
for f in args.files:
if not os.path.isfile(f):
tty.die("Not a file: %s" % f)
stage = Stage(f)
try:
stage.fetch()
checksum = spack.util.crypto.checksum(hashlib.md5, stage.archive_file)
print "%s %s" % (checksum, f)
except FailedDownloadError, e:
tty.msg("Failed to fetch %s" % url)
continue
finally:
stage.destroy()
else:
if not can_access(f):
tty.die("Cannot read file: %s" % f)