def parseOptions(): """parse command line options and save the values""" args = KCmdLineArgs.parsedArgs() Internal.app = APP Options.playOpen |= args.isSet('playopen') Options.showRulesets|= args.isSet('rulesets') Options.rulesetName = str(args.getOption('ruleset')) if args.isSet('host'): Options.host = str(args.getOption('host')) if args.isSet('player'): Options.player = str(args.getOption('player')) if args.isSet('ai'): Options.AI = str(args.getOption('ai')) if args.isSet('csv'): Options.csv = str(args.getOption('csv')) if args.isSet('socket'): Options.socket = str(args.getOption('socket')) SingleshotOptions.game = str(args.getOption('game')) Options.gui |= args.isSet('gui') if args.isSet('table'): SingleshotOptions.table = int(args.getOption('table')) if args.isSet('join'): SingleshotOptions.join = int(args.getOption('join')) Options.demo |= args.isSet('demo') Options.demo |= not Options.gui Internal.autoPlay = Options.demo msg = Debug.setOptions(str(args.getOption('debug'))) if msg: print msg sys.exit(2) from query import initDb if not initDb(): raise SystemExit('Cannot initialize database') initRulesets() Options.fixed = True # may not be changed anymore
def parseOptions(): """parse command line options and save the values""" args = KCmdLineArgs.parsedArgs() Internal.app = APP Options.playOpen |= args.isSet("playopen") Options.showRulesets |= args.isSet("rulesets") Options.rulesetName = str(args.getOption("ruleset")) if args.isSet("host"): Options.host = str(args.getOption("host")) if args.isSet("player"): Options.player = unicodeString(args.getOption("player")) if args.isSet("rounds"): Options.rounds = int(args.getOption("rounds")) if args.isSet("ai"): Options.AI = str(args.getOption("ai")) if args.isSet("csv"): Options.csv = str(args.getOption("csv")) if args.isSet("socket"): Options.socket = str(args.getOption("socket")) if args.isSet("port"): Options.port = str(args.getOption("port")) SingleshotOptions.game = str(args.getOption("game")) Options.gui |= args.isSet("gui") if args.isSet("table"): SingleshotOptions.table = int(args.getOption("table")) if args.isSet("join"): SingleshotOptions.join = int(args.getOption("join")) Options.demo |= args.isSet("demo") Options.demo |= not Options.gui Internal.autoPlay = Options.demo msg = Debug.setOptions(str(args.getOption("debug"))) if msg: Internal.logger.debug(msg) logging.shutdown() sys.exit(2) from query import initDb if not initDb(): raise SystemExit("Cannot initialize database") initRulesets() Options.fixed = True # may not be changed anymore
"""will be called for all events""" from log import EventData EventData(receiver, event) return QObject.eventFilter(self, receiver, event) from util import gitHead if os.name == 'nt': _ = os.path.dirname(os.path.realpath(__file__)) if _.endswith('.zip'): # cx_freeze os.chdir(os.path.dirname(_)) ABOUT = About() KCmdLineArgs.init(sys.argv, ABOUT.about) KCmdLineArgs.addCmdLineOptions(defineOptions()) APP = KApplication() parseOptions() if hasattr(QGuiApplication, 'setDesktopFileName'): QGuiApplication.setDesktopFileName('org.kde.kajongg') if Debug.neutral: KGlobal.translation = None if Debug.events: EVHANDLER = EvHandler() APP.installEventFilter(EVHANDLER) from config import SetupPreferences
class EvHandler(QObject): """an application wide event handler""" def eventFilter(self, receiver, event): """will be called for all events""" from log import EventData EventData(receiver, event) return QObject.eventFilter(self, receiver, event) from util import gitHead ABOUT = About() KCmdLineArgs.init(sys.argv, ABOUT.about) KCmdLineArgs.addCmdLineOptions(defineOptions()) if usingQt4: KApplication.setGraphicsSystem("raster") APP = KApplication() parseOptions() if Debug.neutral: KGlobal.locale().setLanguage("en_US") if Debug.events: EVHANDLER = EvHandler() APP.installEventFilter(EVHANDLER) from config import SetupPreferences