swc-installation-test-2.py: Give suggested install hints
authorW. Trevor King <wking@tremily.us>
Tue, 1 Jan 2013 12:41:28 +0000 (07:41 -0500)
committerW. Trevor King <wking@tremily.us>
Tue, 1 Jan 2013 14:49:48 +0000 (09:49 -0500)
I can't give package-specific links yet, but they will hopefully be in
place soon.  I made the "email your instructor" suggestion optional,
because it is easy for me to imagine a course large enough that the
instructor could not field all requests.  To disable, change

  print_suggestions(instructor_fallback=True)

to

  print_suggestions(instructor_fallback=False)

swc-installation-test-2.py

index 149eb59753e4eecf999b891a8ec31a25b85cda29..15125ee75f90095547cde57a8dc1e9e2d5dfc023 100755 (executable)
@@ -88,8 +88,11 @@ class DependencyError (Exception):
         self.message = message
 
     def __str__(self):
-        return 'check for {0} failed:\n{1}'.format(
-            self.checker.full_name(), self.message)
+        url = 'http://software-carpentry.org/setup/'  # TODO: per-package URL
+        return 'check for {0} failed:\n{1}\n{2}\n{3}'.format(
+            self.checker.full_name(), self.message,
+            'For instructions on installing an up-to-date version, see',
+            url)
 
 
 def check(checks=None):
@@ -492,8 +495,21 @@ def print_system_info():
         print('  {0}={1}'.format(key, value))
     print('==================')
 
+def print_suggestions(instructor_fallback=True):
+    print()
+    print('For suggestions on installing missing packages, see')
+    print('http://software-carpentry.org/setup/')
+    print('')
+    print('For instructings on installing a particular package,')
+    print('see the failure message for that package printed above.')
+    if instructor_fallback:
+        print('')
+        print('For help, email the *entire* output of this script to')
+        print('your instructor.')
+
 
 if __name__ == '__main__':
     if not check(_sys.argv[1:]):
         print()
         print_system_info()
+        print_suggestions(instructor_fallback=True)