コード例 #1
0
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()
コード例 #2
0
 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)
コード例 #3
0
 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
         )
コード例 #4
0
    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)
コード例 #5
0
    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)
コード例 #6
0
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
コード例 #7
0
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
コード例 #8
0
 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
コード例 #9
0
ファイル: paths.py プロジェクト: EdwardBetts/fs-uae-launcher
 def get_base_dir(cls, slash=False):
     path = fsboot.base_dir()
     path = cls.get_real_case(path)
     if slash:
         path += "/"
     return path
コード例 #10
0
    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()
コード例 #11
0
 def get_base_dir(cls, slash=False):
     path = fsboot.base_dir()
     path = cls.get_real_case(path)
     if slash:
         path += "/"
     return path