Exemple #1
0
    def get_corename(self):
        if self.launcher_params is not None and self.launcher_params.get(
                'core') is not None:
            core = self.launcher_params['core']
        else:
            core = self.get_retroarch_property('core')

        coreinfo = ConfigManager.get_instance().get_config('coreinfo')
        if coreinfo is None:
            coreinfo = ConfigManager.get_instance().load_config(
                'cores', extension='info', skip_inst_dir=True)

        if coreinfo is not None:
            if core is not None and coreinfo.has_section(core):
                return coreinfo[core]['corename'].replace('"', '')

        if len(self.game_data) > 0:  # added for configuring ScummVM
            config = self.get_config()
            if config is not None and config.has_section(
                    self.game_data['platform']):
                info_file = config['Launcher'][
                    'cores location'] + '/' + core + '.info'

                with open(info_file) as f:
                    for line in f:
                        line = line.strip()
                        if line.startswith('corename'):
                            *_ignore, corename = line.rpartition('=')
                            corename = corename.replace('"', '')
                            return corename.strip()

        return ''
    def get_implementation(self,
                           feature=None,
                           name=None,
                           ignore_versions=False,
                           version=None):
        the_implementation = None
        if name is not None:
            for implementation in self.implementations:
                if implementation.name == name:
                    the_implementation = implementation
                    break

        if the_implementation is None and feature is not None:
            #            feature = feature.lower()

            # TODO try to get this changed to:
            # TODO self.get_config_value(feature) or self.get_config_value('Defaults.' + feature)
            # The classes inheriting from Plugin should not have different versions
            config = self.get_config(ignore_versions=True)
            if config is not None:
                if config.has_section('Defaults') and config['Defaults'].get(
                        feature) is not None:
                    name = config['Defaults'].get(feature)
                    for implementation in self.implementations:
                        if implementation.name == name:
                            the_implementation = implementation
                            break

            if the_implementation is None:
                for implementation in self.implementations:
                    # A hack until I rewrite the config stuff. Very annoying having mismatches simply due to case.
                    for a_feature in implementation.supported_implementations:
                        if feature.lower() == a_feature.lower():
                            the_implementation = implementation
                            break
                    # if feature in implementation.supported_implementations:
                    #     the_implementation = implementation
                    #     break

        if the_implementation is None:
            the_implementation = self.implementations[0]

        if not ignore_versions:
            if version is None:
                version = the_implementation.get_default_version()

            if version is not None:
                ConfigManager.get_instance().find_config_file(
                    the_implementation.get_plugin_name() + '_' + version,
                    skip_inst_dir=True,
                    must_exist=True)
            the_implementation.version = version
        return the_implementation
    def get_default_version(self):
        config = ConfigManager.get_instance().load_config(
            self.get_plugin_name(), skip_inst_dir=True, must_exist=True)

        if config.has_section('General') and config['General'].get(
                'Default version') is not None:
            return config['General']['Default version']

        config_files = ConfigManager.get_instance().find_config_files(
            self.get_plugin_name(), skip_inst_dir=False, starts_with=True)
        if len(config_files) == 0:
            raise Exception('No configuration files found for \'' +
                            self.get_plugin_name() + '\'.')

        if len(config_files) == 1 and config is not None:
            return None

        versions = []

        for version in [
                config_file[len(self.get_plugin_name()) + 1:][:-4]
                for config_file in config_files
        ]:
            if len(version) == 0:
                continue

            if len(version.split('.')) > 4:
                continue

            for i in range(4 - len(version.split('.'))):
                version += '.0'
            major, minor, update, other, *_ignore = version.split('.')

            if len(_ignore) > 0:
                continue

            try:
                versions.append(
                    (int(major), int(minor), int(update), int(other)))
            except ValueError:
                continue
        versions.sort()

        index = 0
        version = str(versions[-1][index])
        while ConfigManager.get_instance().\
                find_config_file(self.get_plugin_name() + '_' + version, skip_inst_dir=True) is None:
            index += 1
            version += '.' + str(versions[-1][index])

        return version
Exemple #4
0
def add_game(game_desc_file, icon_file):
    if not os.path.isfile(game_desc_file):
        print('Descriptor file ' + game_desc_file + ' does not exist.')
        sys.exit(1)

    if not game_desc_file.endswith('.game'):
        print('Wrong extension type')

    game_descriptor = configparser.ConfigParser(strict=False)
    game_descriptor.read(game_desc_file)
    # TODO Reconsider adding the ID here. Don't like it.
    game_descriptor.set(
        'Game', 'ID',
        game_desc_file[game_desc_file.rfind('/') + 1:len(game_desc_file) - 5])

    # TODO Consider moving this somewhere else so that it will only be done once
    config = ConfigManager.get_instance().load_config('game-launcher',
                                                      skip_inst_dir=True)

    launcher = init_launcher(game_descriptor, config, adding_game=True)

    if launcher.game_data.get('core') is not None and launcher.game_data[
            'core'].endswith('scummvm_libretro.so'):
        add_scummvm_libretro_game(launcher, game_desc_file)
    else:
        add_descriptor(game_desc_file)
    add_menu_entry(launcher, game_descriptor['Game'])
    if icon_file is not None:
        icon_creator.add_icon(icon_file, config)
    def verify_config(self, config_file, version):
        config = ConfigManager.get_instance().load_config(config_file,
                                                          save_config=False)

        self.verify_location_property(config['Launcher'], 'Kickstart Location',
                                      version)
        self.verify_location_property(config['Launcher'], 'Shader location',
                                      version)
Exemple #6
0
def run():
    global t
    config = ConfigManager.get_instance(path)
    for station in config.config['stations']:
        u.update(station)
        print("updating {}".format(station))
    t = Timer(config.config['timer'], run)  #TODO specify time in config
    t.start()
    def verify_version(self, config_file):
        config = ConfigManager.get_instance().load_config(config_file, save_config=False)
        _ignore, version = config_file.split('_', 1)

        if config['Launcher'].get('Executable') is None:
            raise Exception('Executable property not found for ' + self.name + ' version ' + version)
        if not os.path.exists(config['Launcher']['Executable']):
            raise Exception('Executable \'' + config['Executable'] + '\' not found for ' +
                            self.name + ' version ' + version)
    def verify_versions(self):
        super().verify_versions()

        config = ConfigManager.get_instance().load_config(self.get_plugin_name(), save_config=False)

        if config is None:
            return

        if not config.has_section('General'):
            raise Exception('Configuration file for ' + self.name + ' does not contain a General section.')
        if config['General'].get('Config Location') is None:
            raise Exception('Config location property not found for ' + self.name + '.')
    def verify_versions(self):
        config_files = ConfigManager.get_instance().find_config_files(
            self.name, skip_inst_dir=True)

        if len(config_files) == 0:
            return

        for config_file in config_files:
            *_ignore, config_file_name = config_file.rpartition('/')
            if self.name + '.cfg' == config_file_name:
                self.verify()
            else:
                self.verify_version(config_file[:-4])
Exemple #10
0
def launch_game(id):
    if ConfigManager.get_instance().find_config_file(
            id, extension='game', skip_inst_dir=False) is None:
        raise Exception('Game ' + id + ' not found.')

    game_descriptor = ConfigManager.get_instance().load_config(
        id, extension='game', skip_inst_dir=True)
    # TODO Reconsider adding the ID here. Don't like it.
    game_descriptor.set('Game', 'ID', id)

    # TODO Consider moving this somewhere else so that it will only be done once
    # TODO this config file contains launcher specific config...
    # TODO the name game-launcher should be changed to the-games-collector.
    # Also, this is the file that should be replaced by another file (for testing). This config file should contain
    # the information that indicates where the user directories are (or you should be able to override them from here)
    # This should make it possible to remove the test-specific parameters.
    config = ConfigManager.get_instance().load_config('game-launcher',
                                                      skip_inst_dir=True)

    launcher = init_launcher(game_descriptor, config)

    used_mappers = None
    if game_descriptor.has_section('Controls'):
        used_mappers = get_used_mappers(game_descriptor['Controls'])

    check_optical_disk(launcher.game_data, config, game_descriptor['Game'])

    activate_input_mappers(used_mappers)
    try:
        configure_env(launcher)

        # # TODO: Figure out what to do with the line below
        # launcher.game_data['platform_config'] = config['General']['Platform Config']

        launcher.launch_game()
    finally:
        revert_env(launcher)
        deactivate_input_mappers(used_mappers)
Exemple #11
0
def validate_all():
    config = ConfigManager.get_instance().load_config('game-launcher',
                                                      skip_inst_dir=True)
    # TODO remove hard-coded config locations
    files = glob.glob(
        os.environ.get('HOME') + '/.config/the-games-collector/*.game')
    for file in files:
        game_descriptor = configparser.ConfigParser(strict=False)
        game_descriptor.read(file)

        try:
            init_launcher(game_descriptor, config)
        except:
            print(file)
            raise
Exemple #12
0
    def activate(self):
        default_mapping_data = {}

        with open(self.install_dir + '/mapper-0.74.map',
                  'r') as default_mappings:
            for line in default_mappings:
                key, *_ignore = line.split(' ')
                default_mapping_data[key] = line

        for mapping in self.input_mappings:
            default_mapping_data[mapping['virtual']] = mapping[
                'virtual'] + ' "key ' + mapping['physical'] + '"' + os.linesep

        game_root = ConfigManager.get_instance().get_config(
            'Game Config')['game_root']
        with open(game_root + '/mapper-0.74.map', 'w') as mappings_file:
            for line in default_mapping_data.values():
                mappings_file.write(line)
Exemple #13
0
    def verify_version(self, config_file):
        super().verify_version(config_file)

        config = ConfigManager.get_instance().load_config(config_file,
                                                          save_config=False)

        _ignore, version = config_file.split('_', 1)

        if config['Launcher'].get('Cores Location') is None:
            raise Exception(
                'The property \'Cores Location\' was not found for ' +
                self.name + ' version ' + version)

        if not os.path.exists(config['Launcher']['Cores Location']):
            raise Exception('The cores location path \'' +
                            config['Launcher']['Cores Location'] +
                            '\' specified in ' + self.name + ' version ' +
                            version + ' does not exist.')
    def get_config(self, ignore_versions=False):
        if ConfigManager.get_instance().get_config(
                self.get_plugin_name()) is not None:
            return ConfigManager.get_instance().get_config(
                self.get_plugin_name())

        config = ConfigManager.get_instance().load_config(
            self.get_plugin_name(), save_config=False)

        if not ignore_versions and self.version is not None:
            version_config = ConfigManager.get_instance().load_config(
                self.get_plugin_name() + '_' + self.version, save_config=False)
            if version_config is not None:
                ConfigManager.merge(version_config, config)
                config = version_config

        if config is not None:
            ConfigManager.get_instance().set_config(self.get_plugin_name(),
                                                    config)

        return config
    def get_definitions(self):
        if self.definitions is None:
            self.definitions = ConfigManager.get_instance().load_config(self.name, extension='mapper', skip_user_dirs=True, must_exist=True)

        return self.definitions
Exemple #16
0
launch_parser.add_argument('-i', '--installation-location')

launch_parser = sub_parsers.add_parser('configure')
launch_parser.set_defaults(action='configure')
launch_parser.add_argument('id')

launch_parser = sub_parsers.add_parser('validate-all')
launch_parser.set_defaults(action='validate-all')
launch_parser.add_argument('-c', '--config-location')
launch_parser.add_argument('-i', '--installation-location')

args = parser.parse_args()

if args.action == 'play':
    if args.config_location is not None:
        ConfigManager.get_instance().set_user_dir(args.config_location)
    if args.installation_location is not None:
        ConfigManager.get_instance().set_inst_dir(args.installation_location)

install_dir = os.path.dirname(os.path.realpath(__file__))
game_launcher = GameLauncher()
game_launcher.init(install_dir)

input_mapper = InputMapper()
input_mapper.init(install_dir)

display_handler = DisplayHandler()
display_handler.init(install_dir)

if args.action == 'add':
    add_game(args.descriptor, args.icon)
Exemple #17
0
def get_data():
    conf = ConfigManager.get_instance('config')
    dbman = DBManager('delays', 'all', conf.config['conn_string'])
    return pd.DataFrame(list(dbman.get_all()))
Exemple #18
0
 def __init__(self, path):
     config = ConfigManager.get_instance(path)
     self.dbman = DBManager('delays',
                            'all',
                            conn_string=config.config['conn_string'])
 def init(self, install_dir):
     self.install_dir = install_dir
     self.load_plugins('plugins.launchers', GameLauncher)
     ConfigManager.get_instance().set_config('Game Config', self.game_data)