From: W. Trevor King Date: Tue, 26 Feb 2013 03:51:32 +0000 (-0500) Subject: swc-installation-test-2.py: Add --help and --verbose X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e383f75b7c735d034bc6e2fc7f63e1e1d8f36269;p=swc-setup-installation-test.git swc-installation-test-2.py: Add --help and --verbose The system information is useful for troubleshooting a student's installation problems, but it is probably less useful for the student themselves. Turn off this troubleshooting information by default and require the --verbose option to re-enable it. If we didn't have to maintain support for Python 2.6, we could use argparse instead of optparse. The optparse module is deprecated for 2.7, 3.2, and later, but it is still part of the stdandard library. Also update the README to point out --verbose. --- diff --git a/setup/README.md b/setup/README.md index aba09a9..ee383e3 100644 --- a/setup/README.md +++ b/setup/README.md @@ -21,11 +21,29 @@ If you see something like: $ python swc-installation-test-2.py check virtual-shell... fail … - For instructings on installing a particular package, - see the failure message for that package printed above. + check for command line shell (virtual-shell) failed: + command line shell (virtual-shell) requires at least one of the following dependencies + For instructions on installing an up-to-date version, see + http://software-carpentry.org/setup/ + causes: + check for Bourne Again Shell (bash) failed: + could not find 'bash' executable for Bourne Again Shell (bash) + For instructions on installing an up-to-date version, see + http://software-carpentry.org/setup/ … -follow the suggestions to try and install any missing software. +follow the suggestions to try and install any missing software. For +additional troubleshooting information, you can use the `--verbose` +option: + + $ python swc-installation-test-2.py --verbose + check virtual-shell... fail + … + ================== + System information + ================== + os.name : posix + … Instructors =========== diff --git a/setup/swc-installation-test-2.py b/setup/swc-installation-test-2.py index 16a10ee..8449429 100755 --- a/setup/swc-installation-test-2.py +++ b/setup/swc-installation-test-2.py @@ -799,8 +799,18 @@ def print_suggestions(instructor_fallback=True): if __name__ == '__main__': + import optparse as _optparse + + parser = _optparse.OptionParser(usage='%prog [options] [check...]') + epilog = __doc__ + parser.format_epilog = lambda formatter: '\n' + epilog + parser.add_option( + '-v', '--verbose', action='store_true', + help=('print additional information to help troubleshoot ' + 'installation issues')) + options,args = parser.parse_args() try: - passed = check(_sys.argv[1:]) + passed = check(args) except InvalidCheck as e: print("I don't know how to check for {0!r}".format(e.check)) print('I do know how to check for:') @@ -812,7 +822,8 @@ if __name__ == '__main__': print(' {0}'.format(key)) _sys.exit(1) if not passed: - print() - print_system_info() - print_suggestions(instructor_fallback=True) + if options.verbose: + print() + print_system_info() + print_suggestions(instructor_fallback=True) _sys.exit(1)