Prompt the user about checksums only if interactive.

This commit is contained in:
Todd Gamblin 2014-11-16 15:26:00 -08:00
parent eba13b8653
commit 321a3a55c7

View File

@ -615,12 +615,19 @@ def do_fetch(self):
if spack.do_checksum and not self.version in self.versions: if spack.do_checksum and not self.version in self.versions:
tty.warn("There is no checksum on file to fetch %s safely." tty.warn("There is no checksum on file to fetch %s safely."
% self.spec.format('$_$@')) % self.spec.format('$_$@'))
ignore = tty.get_yes_or_no(" Fetch anyway?", default=False)
msg = "Add a checksum or use --no-checksum to skip this check." # Ask the user whether to skip the checksum if we're
if ignore: # interactive, but just fail if non-interactive.
tty.msg("Fetching with no checksum.", msg) checksum_msg = "Add a checksum or use --no-checksum to skip this check."
else: ignore_checksum = False
raise FetchError("Will not fetch %s." % self.spec.format('$_$@'), msg) if sys.stdout.isatty():
ignore_checksum = tty.get_yes_or_no(" Fetch anyway?", default=False)
if ignore_checksum:
tty.msg("Fetching with no checksum.", checksum_msg)
if not ignore_checksum:
raise FetchError(
"Will not fetch %s." % self.spec.format('$_$@'), checksum_msg)
self.stage.fetch() self.stage.fetch()