diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2014-11-08 23:20:01 -0800 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2014-11-08 23:20:01 -0800 |
commit | eba13b865314b4de0b8767acf5232713d6deff75 (patch) | |
tree | 96d05165025bd52d326ada79171bc8e046b21b12 /lib | |
parent | 79414947aef73ca48b9b2810c68cac34472efc37 (diff) | |
download | spack-eba13b865314b4de0b8767acf5232713d6deff75.tar.gz spack-eba13b865314b4de0b8767acf5232713d6deff75.tar.bz2 spack-eba13b865314b4de0b8767acf5232713d6deff75.tar.xz spack-eba13b865314b4de0b8767acf5232713d6deff75.zip |
Checksum warning now prompts for override.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/llnl/util/tty/__init__.py | 27 | ||||
-rw-r--r-- | lib/spack/spack/package.py | 13 |
2 files changed, 35 insertions, 5 deletions
diff --git a/lib/spack/llnl/util/tty/__init__.py b/lib/spack/llnl/util/tty/__init__.py index 40cae11200..652d1cc1a8 100644 --- a/lib/spack/llnl/util/tty/__init__.py +++ b/lib/spack/llnl/util/tty/__init__.py @@ -114,6 +114,33 @@ def get_number(prompt, **kwargs): return number +def get_yes_or_no(prompt, **kwargs): + default_value = kwargs.get('default', None) + + if default_value is None: + prompt += ' [y/n] ' + elif default_value is True: + prompt += ' [Y/n] ' + elif default_value is False: + prompt += ' [y/N] ' + else: + raise ValueError("default for get_yes_no() must be True, False, or None.") + + result = None + while result is None: + ans = raw_input(prompt).lower() + if not ans: + result = default_value + if result is None: + print "Please enter yes or no." + else: + if ans == 'y' or ans == 'yes': + result = True + elif ans == 'n' or ans == 'no': + result = False + return result + + def hline(label=None, **kwargs): """Draw an optionally colored or labeled horizontal line. Options: diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index b5340fa226..e7905cb410 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -613,11 +613,14 @@ class Package(object): raise ValueError("Can only fetch concrete packages.") if spack.do_checksum and not self.version in self.versions: - raise FetchError( - "Cannot fetch %s safely; there is no checksum on file for version %s." - % (self.name, self.version), - "Add a checksum to the package file, or use --no-checksum to " - "skip this check.") + 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) self.stage.fetch() |