Эх сурвалжийг харах

Streamline diagnostic for missing modules/libraries.

Keir Fraser 4 жил өмнө
parent
commit
1e0ff604fc

+ 3 - 3
scripts/greaseweazle/image/ipf.py

@@ -254,10 +254,10 @@ def open_libcaps():
             pass
     if "lib" not in locals():
         print("""\
-ERROR: Could not find SPS/CAPS IPF decode library.
-For installation instructions please read:
+** Could not find SPS/CAPS IPF decode library
+For installation instructions please read the wiki:
 <https://github.com/keirf/Greaseweazle/wiki/IPF-Images>""")
-        sys.exit()
+        sys.exit(1)
     
     # We have opened the library. Now initialise it.
     res = lib.CAPSInit()

+ 15 - 20
scripts/gw.py

@@ -11,36 +11,31 @@
 
 import sys
 import importlib
-import platform
+
+missing_modules = []
 
 try:
     import bitarray
 except ModuleNotFoundError:
-    print("""\
-Please install module 'bitarray'. This may require a C compiler.""")
-    if platform.system() == "Windows":
-        print("""\
-Windows: Either install Visual Studio, or download a pre-built bitarray
-wheel from https://lfd.uci.edu/~gohlke/pythonlibs/#bitarray""")
-    elif platform.system() == "Darwin":
-        print("""\
-macOS: Install Xcode from App Store.""")
-    else:
-        print("""\
-Linux: Install GCC using your package manager (eg. apt install gcc)""")
-    sys.exit()
-
+    missing_modules.append("bitarray")
+    
 try:
     import crcmod
 except ModuleNotFoundError:
-    print("Please install module 'crcmod'.")
-    sys.exit()
-
+    missing_modules.append("crcmod")
+    
 try:
     import serial.tools.list_ports
 except ModuleNotFoundError:
-    print("Please install module 'pyserial'.")
-    sys.exit()
+    missing_modules.append("pyserial")
+
+if missing_modules:
+    print("""\
+** Missing Python modules: %s
+For installation instructions please read the wiki:
+<https://github.com/keirf/Greaseweazle/wiki/Software-Installation>"""
+          % ', '.join(missing_modules))
+    sys.exit(1)
 
 actions = [ 'read', 'write', 'delays', 'update', 'pin', 'reset' ]
 argv = sys.argv