Przeglądaj źródła

gw.py: Real script in scripts/. Place wrapper in rootdir.

Keir Fraser 5 lat temu
rodzic
commit
bb721ad783
2 zmienionych plików z 16 dodań i 4 usunięć
  1. 9 0
      gw.py
  2. 7 4
      scripts/gw.py

+ 9 - 0
gw.py

@@ -0,0 +1,9 @@
+
+import sys, os
+
+# Update the search path and import the real script
+sys.path[0] = os.path.join(sys.path[0], "scripts")
+import gw
+
+# Execute the real script
+gw.main(sys.argv)

+ 7 - 4
scripts/gw.py

@@ -328,7 +328,7 @@ def update(args):
   print("Done.")
   print("** Now remove the Programming Jumper and reconnect.")
 
-def main(argv):
+def _main(argv):
 
   actions = {
     "read" : read,
@@ -392,9 +392,12 @@ def main(argv):
 
   if not update_mode:
     motor(False)
-  
-if __name__ == "__main__":
+
+def main(argv):
   try:
-    main(sys.argv)
+    _main(argv)
   except CmdError as error:
     print("Command Failed: %s" % error)
+    
+if __name__ == "__main__":
+  main(sys.argv)