示例#1
0
文件: __init__.py 项目: StyXman/satyr
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, 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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
文件: Config.py 项目: Ebolon/pynal
def get_param_options():
    """
    Add the parameters that are to be recognized by pynal to a
    KCmdLineOptions object.

    Options:
      <files> -- A list of files that will be opened after start.
    """
    options = KCmdLineOptions()

    options.add("+[<files>]", ki18n("Files to open on startup."))

    return options
示例#6
0
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_())
示例#7
0
    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"))
示例#8
0
文件: main.py 项目: Tayyib/uludag
if __name__ == '__main__':

    # 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"):
示例#9
0
if __name__ == '__main__':

    # 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)

    # Use raster to make it faster
    QApplication.setGraphicsSystem('raster')

    # 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"))
    options.add("select-component <component>", ki18n("Show main window"))
    KCmdLineArgs.addCmdLineOptions(options)

    app = PmApp()

    # Set exception handler
    sys.excepthook = handleException

    # Run the Package Manager
    app.exec_()

示例#10
0
    parser = OptionParser(usage=usage)

    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()
示例#11
0
# Package Manager Main App
if __name__ == '__main__':

    # 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)

    # Use raster to make it faster
    QApplication.setGraphicsSystem('raster')

    # 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"))
    options.add("select-component <component>", ki18n("Show main window"))
    KCmdLineArgs.addCmdLineOptions(options)

    app = PmApp()

    # Set exception handler
    sys.excepthook = handleException

    # Run the Package Manager
    app.exec_()
示例#12
0
    programName = ki18n("Double Commander")
    version = "1.0"
    description = ki18n("Double Commander KDE helper")
    license = KAboutData.License_GPL
    copyright = ki18n("(C) 2013-2014 Alexander Koblov")
    text = ki18n("none")
    homePage = "doublecmd.sourceforge.net"
    bugEmail = "*****@*****.**"

    aboutData = KAboutData(appName, catalog, programName, version, description,
                           license, copyright, text, homePage, bugEmail)

    KCmdLineArgs.init(sys.argv, aboutData, 0)

    options = KCmdLineOptions()
    options.add("+command", ki18n("Command"))
    options.add("+[URL(s)]", ki18n("Arguments for command"))
    KCmdLineArgs.addCmdLineOptions(options)

    args = KCmdLineArgs.parsedArgs()
    CheckArguments(1)

    app = KApplication()
    command = args.arg(0).toLocal8Bit()
    if command == "properties":
        CheckArguments(2)
        fileList = []
        for index in range(1, args.count()):
            fileList.append(KFileItem(args.url(index), "", 0))

        propertiesDialog = KPropertiesDialog(KFileItemList(fileList))
示例#13
0
    version     = "1.0"
    description = ki18n ("Double Commander KDE helper")
    license     = KAboutData.License_GPL
    copyright   = ki18n ("(C) 2013-2014 Alexander Koblov")
    text        = ki18n ("none")
    homePage    = "doublecmd.sourceforge.net"
    bugEmail    = "*****@*****.**"
    
    aboutData   = KAboutData (appName, catalog, programName, version, description,
                              license, copyright, text, homePage, bugEmail)
    
        
    KCmdLineArgs.init (sys.argv, aboutData, 0)

    options = KCmdLineOptions()
    options.add("+command", ki18n("Command"))
    options.add("+[URL(s)]", ki18n("Arguments for command"))
    KCmdLineArgs.addCmdLineOptions(options)
    
    args = KCmdLineArgs.parsedArgs()
    CheckArguments(1)

    app = KApplication()    
    command = args.arg(0).toLocal8Bit();
    if command == "properties":
      CheckArguments(2)      
      fileList = []  
      for index in range(1, args.count()):
	fileList.append(KFileItem(args.url(index), "", 0))
    
      propertiesDialog = KPropertiesDialog(KFileItemList(fileList));
示例#14
0
    parser = OptionParser(usage=usage)

    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)
示例#15
0
copyright = ki18n("Copyright (c) 2008-2010, Wilbert Berendsen")
text = KLocalizedString()
homepage = "http://www.frescobaldi.org/"
bugs = "*****@*****.**"

aboutData = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homepage, bugs)

aboutData.setTranslator(
    ki18nc("NAME OF TRANSLATORS", "Your name"), ki18nc("EMAIL OF TRANSLATORS", "*****@*****.**")
)

KCmdLineArgs.init(list(sys.argv), aboutData)
KComponentData(aboutData).dirs().addPrefix("@CMAKE_INSTALL_PREFIX@")

options = KCmdLineOptions()
options.add("start <session>", ki18n("Session to start"))
options.add("n").add("new", ki18n("Start a new instance"))
options.add("e").add("encoding <enc>", ki18n("Encoding to use"))
options.add("l").add("line <num>", ki18n("Line number to go to, starting at 1"))
options.add("c").add("column <num>", ki18n("Column to go to, starting at 0"))
options.add("smart", ki18n("Try to use smart line and column numbers"))
options.add("+files", ki18n("LilyPond files to open, may also be textedit URLs"))
KCmdLineArgs.addCmdLineOptions(options)

args = KCmdLineArgs.parsedArgs()

app = not args.isSet("new") and runningApp() or newApp()
if args.isSet("start"):
    app.startSession(args.getOption("start"))
docs = [app.openUrl(args.url(c), args.getOption("encoding")) for c in range(args.count())]
if docs:
    programName = ki18n ("Language Selector")
    version     = "0.3.4"
    description = ki18n ("Language Selector")
    license     = KAboutData.License_GPL
    copyright   = ki18n ("(c) 2008 Canonical Ltd")
    text        = ki18n ("none")
    homePage    = "https://launchpad.net/language-selector"
    bugEmail    = ""

    aboutData	= KAboutData (appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail)

    aboutData.addAuthor(ki18n("Rob Bean"), ki18n("PyQt4 to PyKDE4 port"))
    aboutData.addAuthor(ki18n("Harald Sitter"), ki18n("Developer"))

    options = KCmdLineOptions()
    options.add("!mode ", ki18n("REQUIRED: install, uninstall or select must follow"),  "select")
    options.add("+[install]", ki18n("install a language"))
    options.add("+[uninstall]", ki18n("uninstall a language"))
    options.add("+[select]", ki18n("select a language"))

    KCmdLineArgs.init (sys.argv, aboutData)
    KCmdLineArgs.addCmdLineOptions(options)

    gettext.bindtextdomain("language-selector", "/usr/share/locale")
    gettext.textdomain("language-selector")

    app = KApplication()

    args = KCmdLineArgs.parsedArgs()

    if args.isSet("mode"):