コード例 #1
0
    def do_handle_local_options(self, options: GLib.VariantDict) -> int:

        logging_helpers.init()

        if options.contains('profile'):
            # Incorporate profile name into application id
            # to have a single app instance for each profile.
            profile = options.lookup_value('profile').get_string()
            app_id = '%s.%s' % (self.get_application_id(), profile)
            self.set_application_id(app_id)
            self.profile = profile
        if options.contains('separate'):
            self.profile_separation = True
        if options.contains('config-path'):
            self.config_path = options.lookup_value('config-path').get_string()
        if options.contains('version'):
            from common.defs import version
            print(version)
            return 0
        if options.contains('quiet'):
            logging_helpers.set_quiet(True)
        if options.contains('verbose'):
            logging_helpers.set_verbose(True)
        if options.contains('loglevel'):
            loglevel = options.lookup_value('loglevel').get_string()
            logging_helpers.set_loglevels(loglevel)
        return -1
コード例 #2
0
def parseOpts():
    profile_ = ''
    config_path_ = None
    profile_separation_ = False
    
    try:
        shortargs = 'hqsvl:p:c:'
        # add gtk/gnome session option as gtk_get_option_group is not wrapped
        longargs = 'help quiet separate verbose loglevel= profile= config-path='
        longargs += ' class= name= screen= gtk-module= sync g-fatal-warnings'
        longargs += ' sm-client-id= sm-client-state-file= sm-disable'
        opts = getopt.getopt(sys.argv[1:], shortargs, longargs.split())[0]
    except getopt.error as msg1:
        print(str(msg1))
        print('for help use --help')
        sys.exit(2)
    for o, a in opts:
        if o in ('-h', '--help'):
            out = _('Usage:') + \
                '\n  gajim [options] filename\n\n' + \
                _('Options:') + \
                '\n  -h, --help         ' + \
                    _('Show this help message and exit') + \
                '\n  -q, --quiet        ' + \
                    _('Show only critical errors') + \
                '\n  -s, --separate     ' + \
                    _('Separate profile files completely (even history db and plugins)') + \
                '\n  -v, --verbose      ' + \
                    _('Print xml stanzas and other debug information') + \
                '\n  -p, --profile      ' + \
                    _('Use defined profile in configuration directory') + \
                '\n  -c, --config-path  ' + \
                    _('Set configuration directory') + \
                '\n  -l, --loglevel     ' + \
                    _('Configure logging system') + '\n'
            print(out)
            sys.exit()
        elif o in ('-q', '--quiet'):
            logging_helpers.set_quiet()
        elif o in ('-s', '--separate'):
            profile_separation_ = True
        elif o in ('-v', '--verbose'):
            logging_helpers.set_verbose()
        elif o in ('-p', '--profile'): # gajim --profile name
            profile_ = a
        elif o in ('-l', '--loglevel'):
            logging_helpers.set_loglevels(a)
        elif o in ('-c', '--config-path'):
            config_path_ = a
    return profile_, config_path_, profile_separation_
コード例 #3
0
ファイル: application.py プロジェクト: lemenkov/gajim
 def do_command_line(self, command_line: Gio.ApplicationCommandLine) -> int:
     Gtk.Application.do_command_line(self, command_line)
     options = command_line.get_options_dict()
     if options.contains('quiet'):
         logging_helpers.set_quiet()
     if options.contains('separate'):
         self.profile_separation = True
     if options.contains('verbose'):
         logging_helpers.set_verbose()
     if options.contains('profile'):
         variant = options.lookup_value('profile')
         self.profile = variant.get_string()
     if options.contains('loglevel'):
         variant = options.lookup_value('loglevel')
         string = variant.get_string()
         logging_helpers.set_loglevels(string)
     if options.contains('config-path'):
         variant = options.lookup_value('config-path')
         self.config_path = variant.get_string()
     self.activate()
     return 0
コード例 #4
0
ファイル: gajim.py プロジェクト: kalkin/gajim
                '\n  -p, --profile      ' + \
                    _('Use defined profile in configuration directory') + \
                '\n  -c, --config-path  ' + \
                    _('Set configuration directory') + \
                '\n  -l, --loglevel     ' + \
                    _('Configure logging system') + '\n'
            print out.encode(locale.getpreferredencoding())
            sys.exit()
        elif o in ('-q', '--quiet'):
            logging_helpers.set_quiet()
        elif o in ('-v', '--verbose'):
            logging_helpers.set_verbose()
        elif o in ('-p', '--profile'): # gajim --profile name
            profile_ = a
        elif o in ('-l', '--loglevel'):
            logging_helpers.set_loglevels(a)
        elif o in ('-c', '--config-path'):
            config_path_ = a
    return profile_, config_path_

import locale
profile, config_path = parseOpts()
if config_path:
    config_path = unicode(config_path, locale.getpreferredencoding())
del parseOpts

profile = unicode(profile, locale.getpreferredencoding())

import common.configpaths
common.configpaths.gajimpaths.init(config_path)
del config_path