source: branches/active/character_customization/game/run.py @ 833

Revision 826, 2.8 KB checked in by aspidites, 7 years ago (diff)

Patch by Aspidites:

  • removed debug print statements
  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1#!/usr/bin/env python2
2#   This program is free software: you can redistribute it and/or modify
3#   it under the terms of the GNU General Public License as published by
4#   the Free Software Foundation, either version 3 of the License, or
5#   (at your option) any later version.
6
7#   This program is distributed in the hope that it will be useful,
8#   but WITHOUT ANY WARRANTY; without even the implied warranty of
9#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10#   GNU General Public License for more details.
11
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/>.
14
15#TODO: Modularize this script
16import sys
17import logging
18
19from optparse import OptionParser
20from parpg.settings import Settings
21
22# Python 2.6 or lower
23parser = OptionParser(description='PARPG Launcher Script')
24parser.add_option('-p', '--paths',
25                  default='.',
26                  help='One or more paths to load settings from. If more than '
27                       'one path is given, be sure to surround the value in '
28                       'quotes.')
29parser.add_option('-f', '--logfile',
30                  help='Name of log file to save to')
31parser.add_option('-l', '--loglevel', default='critical',
32                  help='desired output level for log file')
33opts, args = parser.parse_args()
34
35# initialize settings
36paths = opts.paths.split(' ')
37settings = Settings(*paths)
38
39levels = {'debug': logging.DEBUG,
40          'info': logging.INFO,
41          'warning': logging.WARNING,
42          'error': logging.ERROR,
43          'critical': logging.CRITICAL}
44
45#TODO: setup formating
46logging.basicConfig(filename=opts.logfile, level=levels[opts.loglevel])
47logger = logging.getLogger('parpg')
48
49try:
50    sys.path.insert(0, settings.parpg.FifePath)
51except AttributeError:
52    logger.warning('[parpg] section has no FifePath option')
53
54try:
55    from fife import fife
56    from parpg.application import PARPGApplication
57
58    from parpg.common import utils
59except ImportError:
60    #TODO: pay attention to which module actually failed
61    logger.critical("Could not import fife module. Please install fife or add "
62                     "'FifePath' to the [parpg] section of your settings file")
63    sys.exit(1)
64
65# enable psyco if available and in settings file
66try:
67    import psyco
68    psyco_available = True
69except ImportError:
70    logger.warning('Psyco Acceleration unavailable')
71    psyco_available = False
72
73if settings.fife.UsePsyco:
74    if psyco_available:
75        psyco.full()
76        logger.info('Psyco Acceleration enabled')
77    else:
78        logger.warning('Please install psyco before attempting to use it'
79                        'Psyco Acceleration disabled')
80else:
81    logger.info('Psycho Acceleration disabled')
82
83# run the game
84app = PARPGApplication(settings)
85app.run()
Note: See TracBrowser for help on using the repository browser.