1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import sys
17 import logging
18
19 from optparse import OptionParser
20
21 usage = ('usage: %prog [options] settings_path [system_path user_path]\n\n'
22 'The settings_path argument is mandatory and is the directory in \n'
23 'which your system.cfg file is located. Optionally, you may \n'
24 'specify where data files are located (system_path), and where \n'
25 'the user settings and data files should be saved to (user_path)\n\n'
26 'Example: python %prog .')
27
28 parser = OptionParser(description='PARPG Launcher Script', usage=usage)
29 parser.add_option('-f', '--logfile',
30 help='Name of log file to save to')
31 parser.add_option('-l', '--loglevel', default='critical',
32 help='desired output level for log file')
33 parser.add_option('-m', '--module',
34 help='location of the parpg module')
35 opts, args = parser.parse_args()
36
37 if not args:
38 parser.print_help()
39 sys.exit(1)
40
41
42
43 if opts.module:
44 sys.path.insert(0, opts.module)
45
46 from parpg.settings import Settings
47
48 settings = Settings(*args)
49
50 levels = {'debug': logging.DEBUG,
51 'info': logging.INFO,
52 'warning': logging.WARNING,
53 'error': logging.ERROR,
54 'critical': logging.CRITICAL}
55
56
57 logging.basicConfig(filename=opts.logfile, level=levels[opts.loglevel])
58 logger = logging.getLogger('parpg')
59
60 try:
61 sys.path.insert(0, settings.parpg.FifePath)
62 except AttributeError:
63 logger.warning('[parpg] section has no FifePath option')
64
65 try:
66 from fife import fife
67 except ImportError:
68 logger.critical("Could not import fife module. Please install fife or add "
69 "'FifePath' to the [parpg] section of your settings file")
70 sys.exit(1)
71
72 from parpg.application import PARPGApplication
73 from parpg.common import utils
74
75
76 try:
77 import psyco
78 psyco_available = True
79 except ImportError:
80 logger.warning('Psyco Acceleration unavailable')
81 psyco_available = False
82
83 if settings.fife.UsePsyco:
84 if psyco_available:
85 psyco.full()
86 logger.info('Psyco Acceleration enabled')
87 else:
88 logger.warning('Please install psyco before attempting to use it'
89 'Psyco Acceleration disabled')
90 else:
91 logger.info('Psycho Acceleration disabled')
92
93
94 app = PARPGApplication(settings)
95 app.run()
96