def app_main(): fsboot.set("fws", "1") # Calculate base dir before we start messing with sys.argv[0] fsboot.base_dir() app = RunApplication() import workspace.shell if len(sys.argv) == 1: workspace.shell.workspace_open("SYS:System/FileManager", ["VOLUMES:"]) else: workspace.shell.workspace_open(sys.argv[1], sys.argv[2:]) app.run() from fsbc.application import Application Application.wait_for_threads()
def stream(cls, name): path = os.path.join(fsboot.base_dir(), "Workspace", "Fonts", name) try: return open(path, "rb") except FileNotFoundError: return pkg_resources.resource_stream( "workspace.ui", "data/" + name)
def stream(cls, name): path = os.path.join(fsboot.base_dir(), "Workspace", "Fonts", name) try: return open(path, "rb") except FileNotFoundError: return pkg_resources.resource_stream( "workspace.ui", "data/" + name )
def load(self, settings, verbose=True): cp = ConfigParser(interpolation=None) cp.optionxform = str path = settings.path if settings.app and not path: path = settings.app.get_settings_path() if not path: if verbose: print("[SETTINGS] No settings path specified") path = os.path.join(fsboot.base_dir(), "Data", "Settings.ini") if verbose: print("[SETTINGS] Using default", path) if os.path.exists(path): if verbose: print("[SETTINGS] Loading from", path) else: if verbose: print("[SETTINGS] File", path, "does not exist") # Write current settings path back to Settings instance settings.path = path try: cp.read([path], encoding="UTF-8") except Exception as e: if verbose: print("[SETTINGS] Error loading", repr(e)) return try: keys = cp.options("settings") except NoSectionError: return values = {} for key in sorted(keys): if key.startswith("__"): if verbose: print("[SETTINGS] Ignoring", key) continue value = cp.get("settings", key) values[key] = value for arg in sys.argv: if arg.startswith("--settings:"): arg = arg[11:] key, value = arg.split("=", 1) key = key.replace("-", "_") values[key] = value for key in sorted(values.keys()): value = values[key] key = self.rewrite_key(key) settings.set(key, value)
def load(self, settings, verbose=True): cp = ConfigParser(interpolation=None) cp.optionxform = str path = settings.path if settings.app and not path: path = settings.app.get_settings_path() if not path: if verbose: print("[SETTINGS] No settings path specified") path = os.path.join(fsboot.base_dir(), "Data", "Settings.ini") if verbose: print("[SETTINGS] Using default", path) if os.path.exists(path): if verbose: print("[SETTINGS] Loading from", path) else: if verbose: print("[SETTINGS] File", path, "does not exist") # Write current settings path back to Settings instance settings.path = path try: cp.read([path], encoding="UTF-8") except Exception as e: if verbose: print("[SETTINGS] Error loading", repr(e)) return try: keys = cp.options("settings") except NoSectionError: return values = {} for key in sorted(keys): if key.startswith("__"): if verbose: print("[SETTINGS] Ignoring", key) continue value = cp.get("settings", key) values[key] = value for arg in sys.argv: if arg.startswith("--settings:"): arg = arg[11:] key, value = arg.split("=", 1) key = key.replace("-", "_") values[key] = value for key in sorted(values.keys()): value = values[key] key = self.rewrite_key(key) settings.set(key, value)
def host(path): path = expand_assigns(path) # FIXME: make absolute path = path.replace("AmigaForever:", "AmigaForever/") path = path.replace("AmigaOS4.1:", "AmigaOS4.1/") path = path.replace("AmiKit:", "AmiKit/") path = path.replace("ClassicWB:", "ClassicWB/") path = path.replace("Data:", "Data/") path = path.replace("Games:", "Games/") path = path.replace("Media:", "Media/") path = path.replace("Ram Disk:", "Ram Disk/") path = path.replace("Shared:", "Shared/") path = path.replace("Systems:", "Systems/") path = path.replace("Workspace:", "Workspace/") if not os.path.isabs(path): path = os.path.join(fsboot.base_dir(), path) return path
def find_executable_in_plugins_dir(name: str): print("- Find executable in plugins dir") plugin_name = known_executables.get(name) if plugin_name is None: return None base_dir = fsboot.base_dir() plugins_dir = path.join(base_dir, "System") exe_file = find_executable_in_dir_containing_plugin( name, plugins_dir, plugin_name) if exe_file: return exe_file print(" Looking in legacy plugin directories") plugins_dir = path.join(base_dir, "Plugins") exe_file = find_executable_in_dir_containing_plugin( name, plugins_dir, plugin_name) if exe_file: return exe_file plugins_dir = path.join(base_dir, "Data", "Plugins") exe_file = find_executable_in_dir_containing_plugin( name, plugins_dir, plugin_name) if exe_file: return exe_file return None
def get_base_dir(cls): path = fsboot.base_dir() # Configuration and file database depends on path normalization, # especially for cross-platform portable mode. path = Paths.get_real_case(path) return path
def get_base_dir(cls, slash=False): path = fsboot.base_dir() path = cls.get_real_case(path) if slash: path += "/" return path
def load(self, settings, verbose=True): print("-" * 79) print("Loading settings") print("-" * 79) cp = ConfigParser(interpolation=None) cp.optionxform = str path = settings.path if settings.app and not path: path = settings.app.get_settings_path() if not path: if verbose: print("[SETTINGS] No settings path specified") path = os.path.join(fsboot.base_dir(), "Data", "Settings.ini") # if verbose: print("[SETTINGS] Using default", path) if os.path.exists(path): print("[SETTINGS] Loading from", path) else: # if verbose: print("[SETTINGS] File", path, "does not exist") # Write current settings path back to Settings instance values = {} settings.path = path try: cp.read([path], encoding="UTF-8") except Exception as e: # if verbose: print("[SETTINGS] Error loading", repr(e)) # return else: try: keys = cp.options("settings") except NoSectionError: pass else: for key in sorted(keys): if key.startswith("__"): if verbose: print("[SETTINGS] Ignoring", key) continue value = cp.get("settings", key) if key.upper() == key: # Keep all upercase keys as is - for environment # variables specified in advanced settings. pass else: key = key.lower() values[key] = value for arg in sys.argv: if arg.startswith("--settings:"): arg = arg[11:] key, value = arg.split("=", 1) key = key.replace("-", "_") print("[SETTINGS] Loaded from arg:", key, "=", value) values[key] = value for key in sorted(values.keys()): value = values[key] key = self.rewrite_key(key) settings.set(key, value) # Disabled by default to due privacy, but we want to enable it as soon # as possible if the user has enabled it. # AUTOMATIC_ERROR_REPORTS = "automatic_error_reports" # if settings.get(AUTOMATIC_ERROR_REPORTS): # set_automatic_error_reports(True) try: version = cp.get("launcher", "version") except NoSectionError: version = "0.0.0" try: fix_settings(settings, version) except Exception: print("[SETTINGS] Error fixing settings") traceback.print_exc()
def get_base_dir(cls, slash=False): path = fsboot.base_dir() path = cls.get_real_case(path) if slash: path += "/" return path