Skip to content

Commit

Permalink
swc-installation-test-2.py: Add --help and --verbose
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
W. Trevor King committed Feb 26, 2013
1 parent 38520f9 commit e383f75
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
24 changes: 21 additions & 3 deletions setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
===========
Expand Down
19 changes: 15 additions & 4 deletions setup/swc-installation-test-2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:')
Expand All @@ -812,7 +822,8 @@ def print_suggestions(instructor_fallback=True):
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)

0 comments on commit e383f75

Please sign in to comment.