def __init__(self): aboutData = KAboutData(APP_NAME, CATALOG, PROGRAM_NAME, VERSION, DESCRIPTION, LICENSE, COPYRIGHT, TEXT, HOMEPAGE, BUG_EMAIL) aboutData.addAuthor(ki18n("GuoCi"), ki18n("Python 3 port maintainer"), "*****@*****.**", "") aboutData.addAuthor(ki18n("Chris Dekter"), ki18n("Developer"), "*****@*****.**", "") aboutData.addAuthor(ki18n("Sam Peterson"), ki18n("Original developer"), "*****@*****.**", "") aboutData.setProgramIconName(common.ICON_FILE) self.aboutData = aboutData KCmdLineArgs.init(sys.argv, aboutData) options = KCmdLineOptions() options.add("l").add("verbose", ki18n("Enable verbose logging")) options.add("c").add("configure", ki18n("Show the configuration window on startup")) KCmdLineArgs.addCmdLineOptions(options) args = KCmdLineArgs.parsedArgs() self.app = KApplication() try: # Create configuration directory if not os.path.exists(CONFIG_DIR): os.makedirs(CONFIG_DIR) # Create data directory (for log file) if not os.path.exists(DATA_DIR): os.makedirs(DATA_DIR) # Create run directory (for lock file) if not os.path.exists(RUN_DIR): os.makedirs(RUN_DIR) # Initialise logger rootLogger = logging.getLogger() rootLogger.setLevel(logging.DEBUG) if args.isSet("verbose"): handler = logging.StreamHandler(sys.stdout) else: handler = logging.handlers.RotatingFileHandler( LOG_FILE, maxBytes=MAX_LOG_SIZE, backupCount=MAX_LOG_COUNT) handler.setLevel(logging.INFO) handler.setFormatter(logging.Formatter(LOG_FORMAT)) rootLogger.addHandler(handler) if self.__verifyNotRunning(): self.__createLockFile() self.initialise(args.isSet("configure")) except Exception as e: self.show_error_dialog( i18n("Fatal error starting AutoKey.\n") + str(e)) logging.exception("Fatal error starting AutoKey: " + str(e)) sys.exit(1)
def __init__(self, argv, opts): """ Constructor @param argv command line arguments @param opts acceptable command line options """ loc = _localeString() os.environ["KDE_LANG"] = loc aboutData = KAboutData( Program, "kdelibs", ki18n(Program), Version, ki18n(""), KAboutData.License_GPL, ki18n(Copyright), ki18n ("none"), Homepage, BugAddress) sysargv = argv[:] KCmdLineArgs.init(sysargv, aboutData) if opts: options = KCmdLineOptions() for opt in opts: if len(opt) == 2: options.add(opt[0], ki18n(opt[1])) else: options.add(opt[0], ki18n(opt[1]), opt[2]) KCmdLineArgs.addCmdLineOptions(options) KApplication.__init__(self, True) KQApplicationMixin.__init__(self)
def start(): appName = Config.appname catalog = Config.catalog programName = ki18n(Config.readable_appname) version = Config.version description = ki18n("A tablet annotation and journaling application.") license = KAboutData.License_BSD copyright = ki18n("(C) 2009 Dominik Schacht") text = ki18n("Whee, greetings.") homepage = Config.homepage bugemail = "*****@*****.**" aboutData = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homepage, bugemail) KCmdLineArgs.init(sys.argv, aboutData) KCmdLineArgs.addCmdLineOptions(Config.get_param_options()) app = KApplication() Config.init_config() # Init after the KApplication has been created. mw = MainWindow() mw.show() result = app.exec_() return result
def createApp (args=sys.argv): ######################################### # all the bureaucratic init of a KDE App # the appName must not contain any chars besides a-zA-Z0-9_ # because KMainWindowPrivate::polish() calls QDBusConnection::sessionBus().registerObject() # see QDBusUtil::isValidCharacterNoDash() appName = "satyr" catalog = "" programName = ki18n ("satyr") #ki18n required here version = "0.5.0" description = ki18n ("I need a media player that thinks about music the way I think about it. This is such a program.") #ki18n required here license = KAboutData.License_GPL copyright = ki18n ("(c) 2009, 2010 Marcos Dione") #ki18n required here text = ki18n ("none") #ki18n required here homePage = "http://savannah.nongnu.org/projects/satyr/" bugEmail = "*****@*****.**" aboutData = KAboutData (appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail) # ki18n required for first two addAuthor () arguments aboutData.addAuthor (ki18n ("Marcos Dione"), ki18n ("design and implementation")) aboutData.addAuthor (ki18n ("Sebastián Álvarez"), ki18n ("features, bugfixes and testing")) KCmdLineArgs.init (args, aboutData) options= KCmdLineOptions () options.add ("s").add ("skin <skin-name>", ki18n ("skin"), "") options.add ("+path", ki18n ("paths to your music collections")) KCmdLineArgs.addCmdLineOptions (options) app= App () args= KCmdLineArgs.parsedArgs () return app, args
def __init__(self): aboutData = KAboutData(APP_NAME, CATALOG, PROGRAM_NAME, VERSION, DESCRIPTION, LICENSE, COPYRIGHT, TEXT, HOMEPAGE, BUG_EMAIL) aboutData.addAuthor(ki18n("Chris Dekter"), ki18n("Developer"), "*****@*****.**", "") aboutData.addAuthor(ki18n("Sam Peterson"), ki18n("Original developer"), "*****@*****.**", "") aboutData.setProgramIconName(common.ICON_FILE) self.aboutData = aboutData aboutData_py3 = KAboutData(APP_NAME, CATALOG, PROGRAM_NAME_PY3, VERSION, DESCRIPTION_PY3, LICENSE, COPYRIGHT_PY3, TEXT, HOMEPAGE_PY3, BUG_EMAIL_PY3) aboutData_py3.addAuthor(ki18n("GuoCi"), ki18n("Python 3 port maintainer"), "*****@*****.**", "") aboutData_py3.addAuthor(ki18n("Chris Dekter"), ki18n("Developer"), "*****@*****.**", "") aboutData_py3.addAuthor(ki18n("Sam Peterson"), ki18n("Original developer"), "*****@*****.**", "") aboutData_py3.setProgramIconName(common.ICON_FILE) self.aboutData_py3 = aboutData_py3 KCmdLineArgs.init(sys.argv, aboutData) options = KCmdLineOptions() options.add("l").add("verbose", ki18n("Enable verbose logging")) options.add("c").add("configure", ki18n("Show the configuration window on startup")) KCmdLineArgs.addCmdLineOptions(options) args = KCmdLineArgs.parsedArgs() self.app = KApplication() try: # Create configuration directory if not os.path.exists(CONFIG_DIR): os.makedirs(CONFIG_DIR) # Initialise logger rootLogger = logging.getLogger() rootLogger.setLevel(logging.DEBUG) if args.isSet("verbose"): handler = logging.StreamHandler(sys.stdout) else: handler = logging.handlers.RotatingFileHandler(LOG_FILE, maxBytes=MAX_LOG_SIZE, backupCount=MAX_LOG_COUNT) handler.setLevel(logging.INFO) handler.setFormatter(logging.Formatter(LOG_FORMAT)) rootLogger.addHandler(handler) if self.__verifyNotRunning(): self.__createLockFile() self.initialise(args.isSet("configure")) except Exception as e: self.show_error_dialog(i18n("Fatal error starting AutoKey.\n") + str(e)) logging.exception("Fatal error starting AutoKey: " + str(e)) sys.exit(1)
def main(): """Creates an application from the cmd line args and starts a editor window""" KCmdLineArgs.init(sys.argv, ABOUT) opts = KCmdLineOptions() opts.add('+[file]', ki18n('File to open')) KCmdLineArgs.addCmdLineOptions(opts) args = KCmdLineArgs.parsedArgs() urls = [args.url(i) for i in range(args.count())] #wurgs app = KApplication() #KGlobal.locale().setLanguage(['de']) TODO win = Markdowner(urls) win.show() sys.exit(app.exec_())
def __init__(self, args): self.getLogin() self.providerPluginManager = PluginManager("providerplugins","providerplugins", providerplugins.Provider.Provider) aboutData = KAboutData ( "Wrapper", "blubb", ki18n("Wrapper for kontact"), "sdaf", ki18n("Displays a KMessageBox popup"), KAboutData.License_GPL, ki18n("(c) 2010"), ki18n("This is a wrapper for kontact to access the multimobileservice"), "http://puzzle.ch", "*****@*****.**" ) KCmdLineArgs.init(sys.argv, aboutData) cmdoptions = KCmdLineOptions() cmdoptions.add("nr <speed>", ki18n("The phone nr")) cmdoptions.add("smsfile <file>", ki18n("The smsfile")) cmdoptions.add("smstext <text>", ki18n("The smstext")) cmdoptions.add("plugin <string>", ki18n("The pluginname")) KCmdLineArgs.addCmdLineOptions(cmdoptions) app = KApplication() lineargs = KCmdLineArgs.parsedArgs() plugin = self.getRightPlugin(lineargs.getOption("plugin")) plugin.addNr(lineargs.getOption("nr")) if lineargs.getOption("smsfile") != "": plugin.setText(self.file2String(lineargs.getOption("smsfile"))) elif lineargs.getOption("smstext") != "": plugin.setText(lineargs.getOption("smstext")) else: KMessageBox.error(None, i18n("No text defined.."), i18n("Text undefined")) raise RuntimeError("No text defined!") plugin.setConfig(self.config) try: plugin.execute() KMessageBox.information(None, i18n("Your SMS was sendet successfull to "+lineargs.getOption("nr")+" with Plugin "+plugin.getObjectname()), i18n("Success")) except Exception, e: KMessageBox.error(None, i18n(e), i18n("Error"))
# Catch signals signal.signal(signal.SIGINT, signal.SIG_DFL) # Create a dbus mainloop if its not exists if not dbus.get_default_main_loop(): from dbus.mainloop.qt import DBusQtMainLoop DBusQtMainLoop(set_as_default = True) # Initialize Command Line arguments from sys.argv KCmdLineArgs.init(sys.argv, aboutData) # Add Command Line options options = KCmdLineOptions() options.add("show-mainwindow", ki18n("Show main window")) KCmdLineArgs.addCmdLineOptions(options) # Create a unique KDE Application app = KUniqueApplication(True, True) # Set system Locale, we may not need it anymore # It should set just before MainWindow call setSystemLocale() # Create MainWindow manager = MainWindow() # Check if show-mainwindow used in sys.args to show mainWindow args = KCmdLineArgs.parsedArgs() if args.isSet("show-mainwindow"): manager.show()
packages = filter(lambda x: not x.startswith('-'), sys.argv[1:]) argv = list(set(sys.argv[1:]) - set(packages)) argv.append('--nofork') argv.insert(0, sys.argv[0]) if len(sys.argv) > 1: aboutData.setAppName("pm-install") KCmdLineArgs.init(argv, aboutData) # Add Command Line options options = KCmdLineOptions() options.add("hide-summary", ki18n("Hide summary screen")) KCmdLineArgs.addCmdLineOptions(options) app = KUniqueApplication(True, True) setSystemLocale() args = KCmdLineArgs.parsedArgs() window = PmWindow(app, packages, hide_summary=args.isSet("hide-summary")) window.show() app.exec_() else: parser.print_usage() sys.exit(1)