Beispiel #1
0
    def initialize_gui(self):
        if self.gui_initialized:
            return True

        # Set path for gui settings to default user data according to the
        # OpenSlides type. This does not depend on any argument the user might
        # type in.
        openslides_type = detect_openslides_type()
        try:
            default_user_data_path = get_default_user_data_path(openslides_type)
        except PortableDirNotWritable:
            wx.MessageBox(
                _("The portable directory is not writable. Please copy the "
                "openslides portable to a writeable location and start it "
                "again from there"),
                _("Error: Portable directory not writable"),
                wx.OK | wx.ICON_ERROR)
            return False

        self.gui_settings_path = os.path.join(
            default_user_data_path, 'openslides', 'gui_settings.json')
        self.load_gui_settings()
        self.apply_backup_settings()

        self.gui_initialized = True
        return True
Beispiel #2
0
def add_general_arguments(subcommand, arguments):
    """
    Adds the named arguments to the subcommand.
    """
    general_arguments = {}
    openslides_type = detect_openslides_type()

    general_arguments['settings'] = (
        ('-s', '--settings'),
        dict(help="Path to settings file. The file must be a python module. "
             "If if isn't provided, the %s environment variable will be "
             "used. If the environment variable isn't provided too, a "
             "default path according to the OpenSlides type will be "
             "used. At the moment it is %s" %
             (ENVIRONMENT_VARIABLE,
              get_default_settings_path(openslides_type))))
    general_arguments['user_data_path'] = (
        ('-d', '--user-data-path'),
        dict(help=
             'Path to the directory for user specific data files like SQLite3 '
             'database, uploaded media and search index. It is only used, '
             'when a new settings file is created. The given path is only '
             'written into the new settings file. Default according to the '
             'OpenSlides type is at the moment %s' %
             get_default_user_data_path(openslides_type)))
    general_arguments['language'] = (
        ('-l', '--language'),
        dict(
            help='Language code. All customizable strings will be translated '
            'during database setup. See https://www.transifex.com/projects/p/openslides/ '
            'for supported languages.'))
    general_arguments['address'] = (
        (
            '-a',
            '--address',
        ),
        dict(default='0.0.0.0',
             help='IP address to listen on. Default is %(default)s.'))
    general_arguments['port'] = (
        ('-p', '--port'),
        dict(
            type=int,
            default=80,
            help=
            'Port to listen on. Default as admin or root is %(default)d, else 8000.'
        ))

    for argument in arguments:
        try:
            args, kwargs = general_arguments[argument]
        except KeyError:
            raise TypeError(
                'The argument %s is not a valid general argument.' % argument)
        subcommand.add_argument(*args, **kwargs)
Beispiel #3
0
def add_general_arguments(subcommand, arguments):
    """
    Adds the named arguments to the subcommand.
    """
    general_arguments = {}
    openslides_type = detect_openslides_type()

    general_arguments["settings"] = (
        ("-s", "--settings"),
        dict(
            help="Path to settings file. If this isn't provided, the "
            "%s environment variable will be used. "
            "If this isn't provided too, a default path according to the "
            "OpenSlides type will be used. At the moment it is %s"
            % (ENVIRONMENT_VARIABLE, get_default_settings_path(openslides_type))
        ),
    )
    general_arguments["user_data_path"] = (
        ("-d", "--user-data-path"),
        dict(
            help="Path to the directory for user specific data files like SQLite3 "
            "database, uploaded media and search index. This is only used, "
            "when a new settings file is created. The given path is only "
            "written into the new settings file. Default according to the "
            "OpenSlides is at the moment %s" % get_default_user_data_path(openslides_type)
        ),
    )
    general_arguments["language"] = (
        ("-l", "--language"),
        dict(
            help="Language code. All customizable strings will be translated "
            "during database setup. See https://www.transifex.com/projects/p/openslides/ "
            "for supported languages."
        ),
    )
    general_arguments["address"] = (
        ("-a", "--address"),
        dict(default="0.0.0.0", help="IP address to listen on. Default is %(default)s."),
    )
    general_arguments["port"] = (
        ("-p", "--port"),
        dict(type=int, default=80, help="Port to listen on. Default as admin or root is %(default)d, else 8000."),
    )

    for argument in arguments:
        try:
            args, kwargs = general_arguments[argument]
        except KeyError:
            raise TypeError("The argument %s is not a valid general argument." % argument)
        subcommand.add_argument(*args, **kwargs)
Beispiel #4
0
def add_general_arguments(subcommand, arguments):
    """
    Adds the named arguments to the subcommand.
    """
    general_arguments = {}
    openslides_type = detect_openslides_type()

    general_arguments['settings'] = (
        ('-s', '--settings'),
        dict(help="Path to settings file. The file must be a python module. "
                  "If if isn't provided, the %s environment variable will be "
                  "used. If the environment variable isn't provided too, a "
                  "default path according to the OpenSlides type will be "
                  "used. At the moment it is %s" % (
                      ENVIRONMENT_VARIABLE,
                      get_default_settings_path(openslides_type))))
    general_arguments['user_data_path'] = (
        ('-d', '--user-data-path'),
        dict(help='Path to the directory for user specific data files like SQLite3 '
                  'database, uploaded media and search index. It is only used, '
                  'when a new settings file is created. The given path is only '
                  'written into the new settings file. Default according to the '
                  'OpenSlides type is at the moment %s' % get_default_user_data_path(openslides_type)))
    general_arguments['language'] = (
        ('-l', '--language'),
        dict(help='Language code. All customizable strings will be translated '
                  'during database setup. See https://www.transifex.com/projects/p/openslides/ '
                  'for supported languages.'))
    general_arguments['address'] = (
        ('-a', '--address',),
        dict(default='0.0.0.0', help='IP address to listen on. Default is %(default)s.'))
    general_arguments['port'] = (
        ('-p', '--port'),
        dict(type=int,
             default=80,
             help='Port to listen on. Default as admin or root is %(default)d, else 8000.'))

    for argument in arguments:
        try:
            args, kwargs = general_arguments[argument]
        except KeyError:
            raise TypeError('The argument %s is not a valid general argument.' % argument)
        subcommand.add_argument(*args, **kwargs)
Beispiel #5
0
def add_general_arguments(subcommand, arguments):
    """
    Adds the named arguments to the subcommand.
    """
    general_arguments = {}
    openslides_type = detect_openslides_type()

    general_arguments['settings'] = (
        ('-s', '--settings'),
        dict(help="Path to settings file. If this isn't provided, the "
                  "%s environment variable will be used. "
                  "If this isn't provided too, a default path according to the "
                  "OpenSlides type will be used. At the moment it is %s" % (
                      ENVIRONMENT_VARIABLE,
                      get_default_settings_path(openslides_type))))
    general_arguments['user_data_path'] = (
        ('-d', '--user-data-path'),
        dict(help='Path to the directory for user specific data files like SQLite3 '
                  'database, uploaded media and search index. This is only used, '
                  'when a new settings file is created. The given path is only '
                  'written into the new settings file. Default according to the '
                  'OpenSlides is at the moment %s' % get_default_user_data_path(openslides_type)))
    general_arguments['address'] = (
        ('-a', '--address',),
        dict(default='0.0.0.0', help='IP address to listen on. Default is %(default)s.'))
    general_arguments['port'] = (
        ('-p', '--port'),
        dict(type=int,
             default=80,
             help='Port to listen on. Default as admin or root is %(default)d, else 8000.'))

    for argument in arguments:
        try:
            args, kwargs = general_arguments[argument]
        except KeyError:
            raise TypeError('The argument %s is not a valid general argument.' % argument)
        subcommand.add_argument(*args, **kwargs)
Beispiel #6
0
 def test_get_default_user_data_path(self):
     self.assertIn(os.path.join('.local', 'share'), get_default_user_data_path(UNIX_VERSION))
Beispiel #7
0
 def test_get_default_user_data_path(self):
     self.assertIn(os.path.join('.local', 'share'),
                   get_default_user_data_path(UNIX_VERSION))