def app_main(): FSGSDirectories.initialize() Settings.instance().verbose = False Settings.instance().load() print("base_dir", FSGSDirectories.get_base_dir()) print("cache_dir", FSGSDirectories.get_cache_dir()) print("cdroms_dir", FSGSDirectories.get_cdroms_dir()) print("configurations_dir", FSGSDirectories.get_configurations_dir()) print("controllers_dir", FSGSDirectories.get_controllers_dir()) print("covers_dir", FSGSDirectories.get_covers_dir()) print("data_dir", FSGSDirectories.get_data_dir()) print("downloads_dir", FSGSDirectories.downloads_dir()) print("floppies_dir", FSGSDirectories.get_floppies_dir()) print("hard_drives_dir", FSGSDirectories.get_hard_drives_dir()) # print("images_dir", FSGSDirectories.get_images_dir()) print("kickstarts_dir", FSGSDirectories.get_kickstarts_dir()) print("launcher_dir", FSGSDirectories.get_launcher_dir()) print("logs_dir", FSGSDirectories.get_logs_dir()) print("plugins_dir", FSGSDirectories.get_plugins_dir()) # print("portable_dir", FSGSDirectories.portable_dir()) print("save_states_dir", FSGSDirectories.get_save_states_dir()) print("screenshots_dir", FSGSDirectories.get_screenshots_dir()) print("screenshots_output_dir =", FSGSDirectories.screenshots_output_dir()) print("themes_dir", FSGSDirectories.get_themes_dir()) print("titles_dir", FSGSDirectories.get_titles_dir())
def prepare(self): print("LaunchHandler.prepare") if not self.temp_dir: self.temp_dir = tempfile.mkdtemp(prefix="fs-uae-") print("temp dir", self.temp_dir) self.config["floppies_dir"] = self.temp_dir print("state dir", self.get_state_dir()) self.config["state_dir"] = self.get_state_dir() self.config["save_states_dir"] = "" self.config["floppy_overlays_dir"] = "" self.config["flash_memory_dir"] = "" # FIXME: Document or change. Tests needs to be able to disable # saving changes or otherwise be able to start with a clean slate. # FIXME: Change handler is disabled for now # if self.config.get("__save_dir", "") == "0": # pass # else: # self.change_handler = GameChangeHandler(self.temp_dir) self.config["cdroms_dir"] = FSGSDirectories.get_cdroms_dir() self.config[ "configurations_dir" ] = FSGSDirectories.get_configurations_dir() self.config["controllers_dir"] = FSGSDirectories.get_controllers_dir() self.config["hard_drives_dir"] = FSGSDirectories.get_hard_drives_dir() self.config["kickstarts_dir"] = FSGSDirectories.get_kickstarts_dir() self.config["save_states_dir"] = FSGSDirectories.get_save_states_dir() self.config["themes_dir"] = FSGSDirectories.get_themes_dir() # self.prepare_roms() if self.stop_flag: return self.prepare_floppies() if self.stop_flag: return self.prepare_cdroms() if self.stop_flag: return # self.prepare_hard_drives() if self.stop_flag: return # self.copy_hd_files() if self.stop_flag: return self.init_changes() if self.stop_flag: return self.prepare_theme() if self.stop_flag: return self.prepare_extra_settings()
def get_search_path(cls): paths = FSGSDirectories.get_default_search_path() search_path = LauncherSettings.get("search_path") for p in search_path.split(";"): p = p.strip() if not p: continue elif p[0] == "-": p = p[1:] if p in paths: paths.remove(p) else: if p not in paths: paths.append(p) # The Configurations dir is always scanned on startup (whenever # modification time has changed). If we don't include it here too # always, the result will be that the configs sometimes appear (on # startup) and disappear (on scan). if not FSGSDirectories.get_configurations_dir() in paths: paths.append(FSGSDirectories.get_configurations_dir()) # Likewise, we force the Kickstarts directory to always be scanned. if not FSGSDirectories.get_kickstarts_dir() in paths: paths.append(FSGSDirectories.get_kickstarts_dir()) return paths
def config_startup_scan(cls): if cls._config_scanned: return cls._config_scanned = True configs_dir = FSGSDirectories.get_configurations_dir() print("config_startup_scan", configs_dir) print(LauncherSettings.settings) settings_mtime = LauncherSettings.get("configurations_dir_mtime") dir_mtime = cls.get_dir_mtime_str(configs_dir) if settings_mtime == dir_mtime + "+" + str(Database.VERSION): print("... mtime not changed", settings_mtime, dir_mtime) return database = Database.get_instance() file_database = FileDatabase.get_instance() print("... database.find_local_configurations") local_configs = Database.get_instance().find_local_configurations() print("... walk configs_dir") for dir_path, dir_names, file_names in os.walk(configs_dir): for file_name in file_names: # if not file_name.endswith(".fs-uae"): # continue # FIXME: Move extension list somewhere else if not file_name.endswith( ".fs-uae") and not file_name.endswith(".fs-fuse"): continue path = Paths.join(dir_path, file_name) if path in local_configs: local_configs[path] = None # already exists in database continue name, ext = os.path.splitext(file_name) # search = ConfigurationScanner.create_configuration_search( # name) scanner = ConfigurationScanner() print("[startup] adding config", path) file_database.delete_file(path=path) with open(path, "rb") as f: sha1 = hashlib.sha1(f.read()).hexdigest() file_database.add_file(path=path, sha1=sha1) game_id = database.add_configuration( path=path, name=scanner.create_configuration_name(name)) database.update_game_search_terms( game_id, scanner.create_search_terms(name)) for path, config_id in local_configs.items(): if config_id is not None: print("[startup] removing configuration", path) database.delete_game(id=config_id) file_database.delete_file(path=path) print("... commit") database.commit() LauncherSettings.set( "configurations_dir_mtime", cls.get_dir_mtime_str(configs_dir) + "+" + str(Database.VERSION), )
def save_config(): print("SaveButton.save_config") config = get_config(self) database = Database.get_instance() name = LauncherSettings.get("config_name").strip() if not name: print("no config_name") # FIXME: notify user return file_name = name + get_extension_for_config(config) path = os.path.join( FSGSDirectories.get_configurations_dir(), file_name ) with io.open(path, "w", encoding="UTF-8") as f: f.write("# FS-UAE configuration saved by FS-UAE Launcher\n") f.write( "# Last saved: {0}\n".format( datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S") ) ) f.write("\n[fs-uae]\n") keys = sorted(fsgs.config.values.keys()) for key in keys: value = config.get(key) if key.startswith("__"): continue if key in LauncherConfig.no_save_keys_set: continue # elif key == "joystick_port_2_mode" and value == "nothing": # continue # elif key == "joystick_port_3_mode" and value == "nothing": # continue if value == LauncherConfig.default_config.get(key, ""): continue if value: f.write("{0} = {1}\n".format(key, value)) # scanner = ConfigurationScanner() # search = ConfigurationScanner.create_configuration_search(name) # name = scanner.create_configuration_name(name) # print("adding", path) # # deleting the path from the database first in case it already exists # database.delete_configuration(path=path) # database.delete_file(path=path) # database.add_file(path=path) # database.add_configuration( # path=path, uuid="", name=name, scan=0, search=search) file_database = FileDatabase.get_instance() scanner = ConfigurationScanner() print("[save config] adding config", path) file_database.delete_file(path=path) with open(path, "rb") as f: sha1 = hashlib.sha1(f.read()).hexdigest() file_database.add_file(path=path, sha1=sha1) game_id = database.add_configuration( path=path, name=scanner.create_configuration_name(name) ) database.update_game_search_terms( game_id, scanner.create_search_terms(name) ) database.commit() file_database.commit() LauncherSettings.set("__config_refresh", str(time.time())) # Settings.set("config_changed", "0") LauncherConfig.set("__changed", "0")