diff main.py @ 175:94196a3e9c07

Added command line option to manually set a fife path.
author Beliar <KarstenBock@gmx.net>
date Mon, 05 Mar 2012 19:32:52 +0100
parents 5d47ad053aef
children c41299c7e833
line wrap: on
line diff
--- a/main.py	Fri Mar 02 19:42:26 2012 +0100
+++ b/main.py	Mon Mar 05 19:32:52 2012 +0100
@@ -14,38 +14,41 @@
 import logging
 import sys
 from os.path import abspath
-
-from fife.extensions.fife_settings import Setting
+      
+def main(parser):
 
-      
-def main(args, opts):
-    settings = Setting(settings_file="settings.xml")
-    
-    settings.set("parpg","DataPath", abspath(settings.get("parpg","DataPath")))
-    
+    opts, args = parser.parse_args()
+
     levels = {'debug': logging.DEBUG,
               'info': logging.INFO,
               'warning': logging.WARNING,
               'error': logging.ERROR,
               'critical': logging.CRITICAL}
-    
+
     #TODO: setup formating
     logging.basicConfig(filename=opts.logfile, level=levels[opts.loglevel])
     logger = logging.getLogger('parpg')
-    
+
     try:
         old_path = sys.path
-        sys.path = [settings.get("parpg", "FifePath")]
+        if opts.fife_path:
+            sys.path = [opts.fife_path]
         import fife
-    except AttributeError:
-        logger.warning('parpg section has no FifePath option')
     except ImportError:
-        logger.critical("Could not import fife module. Please install fife or add "
-                        "'FifePath' to the parpg section of your settings file")
+        logger.critical("Could not import fife module. Please install fife or set the --fife-path command line value")
+        parser.print_help()
         sys.exit(1)
     finally:
         sys.path = old_path
+
+
+    from fife.extensions.fife_settings import Setting
+
+    settings = Setting(settings_file="settings.xml")
     
+    settings.set("parpg","DataPath", abspath(settings.get("parpg","DataPath")))
+    
+   
     from parpg.application import PARPGApplication
     from parpg.common import utils