comparison 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
comparison
equal deleted inserted replaced
174:230d316cc43b 175:94196a3e9c07
12 # You should have received a copy of the GNU General Public License 12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>. 13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 import logging 14 import logging
15 import sys 15 import sys
16 from os.path import abspath 16 from os.path import abspath
17
18 def main(parser):
17 19
18 from fife.extensions.fife_settings import Setting 20 opts, args = parser.parse_args()
19 21
20
21 def main(args, opts):
22 settings = Setting(settings_file="settings.xml")
23
24 settings.set("parpg","DataPath", abspath(settings.get("parpg","DataPath")))
25
26 levels = {'debug': logging.DEBUG, 22 levels = {'debug': logging.DEBUG,
27 'info': logging.INFO, 23 'info': logging.INFO,
28 'warning': logging.WARNING, 24 'warning': logging.WARNING,
29 'error': logging.ERROR, 25 'error': logging.ERROR,
30 'critical': logging.CRITICAL} 26 'critical': logging.CRITICAL}
31 27
32 #TODO: setup formating 28 #TODO: setup formating
33 logging.basicConfig(filename=opts.logfile, level=levels[opts.loglevel]) 29 logging.basicConfig(filename=opts.logfile, level=levels[opts.loglevel])
34 logger = logging.getLogger('parpg') 30 logger = logging.getLogger('parpg')
35 31
36 try: 32 try:
37 old_path = sys.path 33 old_path = sys.path
38 sys.path = [settings.get("parpg", "FifePath")] 34 if opts.fife_path:
35 sys.path = [opts.fife_path]
39 import fife 36 import fife
40 except AttributeError:
41 logger.warning('parpg section has no FifePath option')
42 except ImportError: 37 except ImportError:
43 logger.critical("Could not import fife module. Please install fife or add " 38 logger.critical("Could not import fife module. Please install fife or set the --fife-path command line value")
44 "'FifePath' to the parpg section of your settings file") 39 parser.print_help()
45 sys.exit(1) 40 sys.exit(1)
46 finally: 41 finally:
47 sys.path = old_path 42 sys.path = old_path
43
44
45 from fife.extensions.fife_settings import Setting
46
47 settings = Setting(settings_file="settings.xml")
48 48
49 settings.set("parpg","DataPath", abspath(settings.get("parpg","DataPath")))
50
51
49 from parpg.application import PARPGApplication 52 from parpg.application import PARPGApplication
50 from parpg.common import utils 53 from parpg.common import utils
51 54
52 # enable psyco if available and in settings file 55 # enable psyco if available and in settings file
53 try: 56 try: