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

Revision 794, 2.7 KB checked in by aspidites, 9 years ago (diff)

Patch by Aspidites

  • added "DataDirectory?" option to [fife] section of system.cfg
  • broke down *File options and made additonal *Directory options

where neccessary

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