Adding the stager to checksum any url that spack can handle
This commit is contained in:
parent
c2bb00ca2f
commit
5850d8530e
@ -30,8 +30,9 @@
|
|||||||
from llnl.util.filesystem import *
|
from llnl.util.filesystem import *
|
||||||
|
|
||||||
import spack.util.crypto
|
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):
|
def setup_parser(subparser):
|
||||||
setup_parser.parser = subparser
|
setup_parser.parser = subparser
|
||||||
@ -45,9 +46,20 @@ def md5(parser, args):
|
|||||||
|
|
||||||
for f in args.files:
|
for f in args.files:
|
||||||
if not os.path.isfile(f):
|
if not os.path.isfile(f):
|
||||||
tty.die("Not a file: %s" % f)
|
stage = Stage(f)
|
||||||
if not can_access(f):
|
try:
|
||||||
tty.die("Cannot read file: %s" % f)
|
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
|
||||||
|
|
||||||
checksum = spack.util.crypto.checksum(hashlib.md5, f)
|
finally:
|
||||||
print "%s %s" % (checksum, f)
|
stage.destroy()
|
||||||
|
else:
|
||||||
|
if not can_access(f):
|
||||||
|
tty.die("Cannot read file: %s" % f)
|
||||||
|
|
||||||
|
checksum = spack.util.crypto.checksum(hashlib.md5, f)
|
||||||
|
print "%s %s" % (checksum, f)
|
||||||
|
Loading…
Reference in New Issue
Block a user