diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2015-02-24 10:42:58 -0800 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2015-02-24 10:42:58 -0800 |
commit | 8eab69fc0b06994ad063efec4d40c418aef49a10 (patch) | |
tree | 764ba29462f20fb1196b9fba1dc3374f9bec2c8f /bin | |
parent | fa21acc470d9c32619b3c67dcce54c7b0a69a07a (diff) | |
parent | ffdb90f39a56e5f0dacefd19ccf85ddd0e7a01c0 (diff) | |
download | spack-0.8.15.tar.gz spack-0.8.15.tar.bz2 spack-0.8.15.tar.xz spack-0.8.15.zip |
Merge branch 'develop' for v0.8.15v0.8.15
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/spack | 79 |
1 files changed, 49 insertions, 30 deletions
@@ -25,7 +25,8 @@ ############################################################################## import sys if not sys.version_info[:2] >= (2,6): - sys.exit("Spack requires Python 2.6. Version was %s." % sys.version_info) + v_info = sys.version_info[:3] + sys.exit("Spack requires Python 2.6 or higher. This is Python %d.%d.%d." % v_info) import os @@ -57,14 +58,16 @@ parser = argparse.ArgumentParser( description='Spack: the Supercomputing PACKage Manager.') parser.add_argument('-V', '--version', action='version', version="%s" % spack.spack_version) -parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', +parser.add_argument('-v', '--verbose', action='store_true', help="Print additional output during builds") -parser.add_argument('-d', '--debug', action='store_true', dest='debug', +parser.add_argument('-d', '--debug', action='store_true', help="Write out debug logs during compile") -parser.add_argument('-k', '--insecure', action='store_true', dest='insecure', +parser.add_argument('-k', '--insecure', action='store_true', help="Do not check ssl certificates when downloading archives.") -parser.add_argument('-m', '--mock', action='store_true', dest='mock', +parser.add_argument('-m', '--mock', action='store_true', help="Use mock packages instead of real ones.") +parser.add_argument('-p', '--profile', action='store_true', + help="Profile execution using cProfile.") # each command module implements a parser() function, to which we pass its # subparser for setup. @@ -84,33 +87,49 @@ if len(sys.argv) == 1: # actually parse the args. args = parser.parse_args() -# Set up environment based on args. -tty.set_verbose(args.verbose) -tty.set_debug(args.debug) -spack.debug = args.debug +def main(): + # Set up environment based on args. + tty.set_verbose(args.verbose) + tty.set_debug(args.debug) + spack.debug = args.debug -spack.spack_working_dir = working_dir -if args.mock: - from spack.packages import PackageDB - spack.db = PackageDB(spack.mock_packages_path) + spack.spack_working_dir = working_dir + if args.mock: + from spack.packages import PackageDB + spack.db = PackageDB(spack.mock_packages_path) -# If the user asked for it, don't check ssl certs. -if args.insecure: - tty.warn("You asked for --insecure, which does not check SSL certificates or checksums.") - spack.curl.add_default_arg('-k') + # If the user asked for it, don't check ssl certs. + if args.insecure: + tty.warn("You asked for --insecure, which does not check SSL certificates or checksums.") + spack.curl.add_default_arg('-k') -# Try to load the particular command asked for and run it -command = spack.cmd.get_command(args.command) -try: - command(parser, args) -except SpackError, e: - if spack.debug: - # In debug mode, raise with a full stack trace. - raise - elif e.long_message: - tty.die(e.message, e.long_message) + # Try to load the particular command asked for and run it + command = spack.cmd.get_command(args.command) + try: + return_val = command(parser, args) + except SpackError, e: + if spack.debug: + # In debug mode, raise with a full stack trace. + raise + elif e.long_message: + tty.die(e.message, e.long_message) + else: + tty.die(e.message) + + except KeyboardInterrupt: + sys.stderr.write('\n') + tty.die("Keyboard interrupt.") + + # Allow commands to return values if they want to exit with some ohter code. + if return_val is None: + sys.exit(0) + elif isinstance(return_val, int): + sys.exit(return_val) else: - tty.die(e.message) + tty.die("Bad return value from command %s: %s" % (args.command, return_val)) -except KeyboardInterrupt: - tty.die("Keyboard interrupt.") +if args.profile: + import cProfile + cProfile.run('main()', sort='tottime') +else: + main() |