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

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

Patch by Aspidites:

  • removed debug print statements
  • Property svn:eol-style set to native
  • Property svn:executable set to *
RevLine 
[825]1#!/usr/bin/env python2
[30]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.
[26]6
[30]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.
[26]11
[30]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/>.
[26]14
[809]15#TODO: Modularize this script
[646]16import sys
[786]17import logging
[544]18
[798]19from optparse import OptionParser
[747]20from parpg.settings import Settings
[544]21
[798]22# Python 2.6 or lower
23parser = OptionParser(description='PARPG Launcher Script')
[825]24parser.add_option('-p', '--paths',
[810]25                  default='.',
[825]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.')
[798]29parser.add_option('-f', '--logfile',
[810]30                  help='Name of log file to save to')
[798]31parser.add_option('-l', '--loglevel', default='critical',
[810]32                  help='desired output level for log file')
[800]33opts, args = parser.parse_args()
[627]34
[787]35# initialize settings
[825]36paths = opts.paths.split(' ')
37settings = Settings(*paths)
[26]38
[786]39levels = {'debug': logging.DEBUG,
40          'info': logging.INFO,
41          'warning': logging.WARNING,
42          'error': logging.ERROR,
43          'critical': logging.CRITICAL}
[26]44
[787]45#TODO: setup formating
[800]46logging.basicConfig(filename=opts.logfile, level=levels[opts.loglevel])
[787]47logger = logging.getLogger('parpg')
[58]48
[787]49try:
[786]50    sys.path.insert(0, settings.parpg.FifePath)
[787]51except AttributeError:
52    logger.warning('[parpg] section has no FifePath option')
[646]53
[786]54try:
55    from fife import fife
56    from parpg.application import PARPGApplication
[646]57
[786]58    from parpg.common import utils
59except ImportError:
60    #TODO: pay attention to which module actually failed
[787]61    logger.critical("Could not import fife module. Please install fife or add "
[786]62                     "'FifePath' to the [parpg] section of your settings file")
63    sys.exit(1)
[646]64
[786]65# enable psyco if available and in settings file
66try:
67    import psyco
68    psyco_available = True
69except ImportError:
[787]70    logger.warning('Psyco Acceleration unavailable')
[786]71    psyco_available = False
[26]72
[786]73if settings.fife.UsePsyco:
74    if psyco_available:
75        psyco.full()
[787]76        logger.info('Psyco Acceleration enabled')
[747]77    else:
[787]78        logger.warning('Please install psyco before attempting to use it'
[786]79                        'Psyco Acceleration disabled')
80else:
[787]81    logger.info('Psycho Acceleration disabled')
[747]82
[786]83# run the game
84app = PARPGApplication(settings)
85app.run()
Note: See TracBrowser for help on using the repository browser.