diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2014-11-16 15:26:00 -0800 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2014-11-16 15:26:00 -0800 |
commit | 321a3a55c73b4f48a5b51f19736d70484cfd4078 (patch) | |
tree | 7f5897d7774d38da8eca65fbb3599d39897ac5d2 | |
parent | eba13b865314b4de0b8767acf5232713d6deff75 (diff) | |
download | spack-321a3a55c73b4f48a5b51f19736d70484cfd4078.tar.gz spack-321a3a55c73b4f48a5b51f19736d70484cfd4078.tar.bz2 spack-321a3a55c73b4f48a5b51f19736d70484cfd4078.tar.xz spack-321a3a55c73b4f48a5b51f19736d70484cfd4078.zip |
Prompt the user about checksums only if interactive.
-rw-r--r-- | lib/spack/spack/package.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index e7905cb410..bb6180c521 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -615,12 +615,19 @@ class Package(object): if spack.do_checksum and not self.version in self.versions: tty.warn("There is no checksum on file to fetch %s safely." % 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." - if ignore: - tty.msg("Fetching with no checksum.", msg) - else: - raise FetchError("Will not fetch %s." % self.spec.format('$_$@'), msg) + + # Ask the user whether to skip the checksum if we're + # interactive, but just fail if non-interactive. + checksum_msg = "Add a checksum or use --no-checksum to skip this check." + ignore_checksum = False + 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() |