#!/usr/bin/python # Copyright (C) 2006-2010 Mortal Coil Games # See LICENSE for details. """ MV3D Client """ import sys import os import uuid uuid # shut up pylint if sys.argv[0].endswith(".exe"): # HACK! Because we do dynamic imports, we need to change the # path a bit so that it looks in the local directory first. sys.path.insert(0, os.path.split(sys.path[0])[0]) try: import psyco except ImportError: psyco = None try: import hotshot.stats except ImportError: hotshot = None from ConfigParser import ConfigParser from twisted.python.usage import Options from twisted.internet import reactor from twisted.python import log import mv3d from mv3d.util.conductor import Conductor from mv3d.client.player import IPlayerClient class MV3DClientOptions(Options): """ Command line arguments that can be used for the MV3D client """ optParameters = [ ('config', 'c', 'client.conf', 'The file to load configuration from.'), ('config-name', 'm', "Client", 'The section name in the config file to read from.'), ] optFlags = [ ('profile', 'p', 'Enable profiling'), ] def opt_version(self): """ Simply print out our version info """ print mv3d.__version__ Options.opt_version(self) def go(): #if psyco is not None: # psyco.full() options = MV3DClientOptions() options.parseOptions() configfile = options["config"] cf = ConfigParser() cf.read(configfile) log.startLoggingWithObserver(log.FileLogObserver(sys.stdout).emit) conductor = Conductor() conductor.configure(options["config-name"], cf) conductor.startService() player = conductor.getLocalService(IPlayerClient) # player.connectAndSelectPC() from mv3d.client.ui.menu import MainMenu main = MainMenu(player.getUI()) main.start() if options["profile"]: prof = hotshot.Profile("RunClient.prof") benchtime = prof.runcall(reactor.run) conductor.stopService() prof.close() stats = hotshot.stats.load("RunClient.prof") stats.strip_dirs() stats.sort_stats('time', 'calls') stats.print_stats(20) else: reactor.run() conductor.stopService() if __name__ == '__main__': go()