changeset 16:f4f3c785b0b1 tip

Added a parpg-path parameter to the run script.
author Beliar <KarstenBock@gmx.net>
date Tue, 20 Mar 2012 13:55:41 +0100
parents 76816b46bd88
children
files parpg.py
diffstat 1 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/parpg.py	Fri Mar 16 07:16:42 2012 +0100
+++ b/parpg.py	Tue Mar 20 13:55:41 2012 +0100
@@ -17,8 +17,6 @@
 from optparse import OptionParser
 from os import path
 
-from parpg.main import main
-
 usage = ('usage: %prog [options] '
          'Example: python %prog .')
 
@@ -29,5 +27,23 @@
                   help='desired output level for log file')
 parser.add_option('-p', '--fife-path',
                   help='Path to the fife module')
+parser.add_option('-m', '--parpg-path',
+                  help='Path to the parpg module')
 
+opts, args = parser.parse_args()
+
+try:
+    old_path = sys.path
+    if opts.parpg_path:
+        sys.path = [opts.parpg_path]
+    import parpg
+except ImportError:
+    print("Could not import parpg module. Please install parpg or set the --parpg-path command line value")
+    parser.print_help()
+    sys.exit(1)
+finally:
+    sys.path = old_path
+
+
+from parpg.main import main
 main(parser)