Exemplo n.º 1
0
 def find_executable(self, name):
     logger.debug("PluginManager.find_executable %s", repr(name))
     try:
         plugin = self.provides()["executable:" + name]
     except KeyError:
         # Did not find executable in plugin, try to find executable
         # bundled with the program.
         if windows:
             exe_name = name + ".exe"
         else:
             exe_name = name
         path = os.path.join(fsboot.executable_dir(), exe_name)
         logger.debug("Checking %s", path)
         if os.path.exists(path):
             logger.debug("Found non-plugin executable %s", path)
             return Executable(path)
         if fsboot.development():
             if name == "x64sc-fs":
                 logger.debug("Lookup hack for vice-fs/x64sc-fs")
                 name = "vice-fs"
             path = os.path.join(fsboot.executable_dir(), "..", name,
                                 exe_name)
             logger.debug("Checking %s", path)
             if os.path.exists(path):
                 logger.debug("Found non-plugin executable %s", path)
                 return Executable(path)
         return None
     return plugin.executable(name)
Exemplo n.º 2
0
 def find_executable(self, name):
     logger.debug("PluginManager.find_executable %s", repr(name))
     try:
         plugin = self.provides()["executable:" + name]
     except KeyError:
         # Did not find executable in plugin, try to find executable
         # bundled with the program.
         if windows:
             exe_name = name + ".exe"
         else:
             exe_name = name
         path = os.path.join(fsboot.executable_dir(), exe_name)
         logger.debug("Checking %s", path)
         if os.path.exists(path):
             logger.debug("Found non-plugin executable %s", path)
             return Executable(path)
         if fsboot.development():
             if name == "x64sc-fs":
                 logger.debug("Lookup hack for vice-fs/x64sc-fs")
                 name = "vice-fs"
             path = os.path.join(
                 fsboot.executable_dir(), "..", name, exe_name
             )
             logger.debug("Checking %s", path)
             if os.path.exists(path):
                 logger.debug("Found non-plugin executable %s", path)
                 return Executable(path)
         return None
     return plugin.executable(name)
Exemplo n.º 3
0
def maybeRunNewerVersionFromPlugin():
    pluginName = getLauncherPluginName()
    launcherDir = getLauncherPluginDirectory()

    # launcherNextDir = f"{launcherDir}.next"
    # if os.path.exists(launcherNextDir):
    #     debug(f"{launcherNextDir} exists")
    #     if os.path.exists(launcherDir):
    #         debug(f"{launcherDir} exists, move away")
    #         if not moveOldPluginDirectory(launcherDir):
    #             debug(f"WARNING: Could not move {launcherDir}")

    #     if os.path.exists(launcherDir):
    #         # Was not moved away
    #         debug(f"Cannot install update for {pluginName}")
    #         # FIXME: GUI warning?
    #         log.warning(f"Cannot install update for {pluginName}")
    #     else:
    #         debug(f"Renaming directory {launcherNextDir} -> {launcherDir}")
    #         os.rename(launcherNextDir, launcherDir)

    if os.path.exists(launcherDir):
        # FIXME: Move to fscore.version?
        from fscore.version import Version
        from launcher.version import VERSION

        try:
            pluginVersion = Updater.getPluginVersionFromDirectory(launcherDir)
            if Version(pluginVersion) > Version(VERSION):
                debug(f"Plugin version ({pluginVersion}) "
                      f"> running version ({VERSION})")
            else:
                debug(f"Plugin version ({pluginVersion}) "
                      f"<= running version ({VERSION})")
                debug("Will continue using current executable")
                return False
        except Exception:
            traceback.print_exc()
            debug("Problem comparing Launcher version")
            debug("Will continue using current executable")
            return False

        if fsboot.development():
            debug("Development mode, will not run plugin executable")
            debug("Will continue using current executable")
            return False

        launcherExecutable = findLauncherExecutable(launcherDir)
        if launcherExecutable is None:
            return False

        # Open file objects and descriptors are not flushed when running exec
        sys.stdout.flush()
        sys.stderr.flush()

        args = sys.argv.copy()
        args[0] = launcherExecutable
        debug(f"Running execv with args {repr(args)}")
        os.execv(args[0], args)
    def plugin_path(cls):
        # Plugins dir location has changed, add several old and new paths here
        # to find plugins in both places (FS-UAE and OpenRetro style).

        result = []

        # $BASE/Plugins/ or $BASE/Data/Plugins/
        plugins_dir = FSGSDirectories.get_plugins_dir()
        result.append(plugins_dir)

        # $BASE/Plugins/
        plugins_dir = os.path.join(FSGSDirectories.get_base_dir(), "Plugins")
        if plugins_dir not in result:
            result.append(plugins_dir)

        # $BASE/Data/Plugins/
        plugins_dir = os.path.join(FSGSDirectories.get_data_dir(), "Plugins")
        if plugins_dir not in result:
            result.append(plugins_dir)

        # # $BASE/Workspace/Expansion/
        # plugins_dir = os.path.join(
        #     FSGSDirectories.get_base_dir(), "Workspace", "Expansion"
        # )
        # if plugins_dir and os.path.isdir(plugins_dir):
        #     result.append(plugins_dir)

        if not fsboot.development():
            if System.macos:
                escape_exe_dir = "../../../../../.."
            else:
                escape_exe_dir = "../../.."
            # FIXME: Check that this contains something known first?
            # System/
            plugins_dir = os.path.normpath(
                os.path.join(fsboot.executable_dir(), escape_exe_dir))
            result.append(plugins_dir)

            # FIXME: Check that this contains something known first?
            # System/Plugins/
            plugins_dir = os.path.normpath(
                os.path.join(fsboot.executable_dir(), escape_exe_dir,
                             "Plugins"))
            result.append(plugins_dir)

        return result
def find_executable(name: str):
    if fsboot.development():
        exe_file = find_executable_in_development_project_dir(name)
        if exe_file:
            return exe_file
    exe_file = find_executable_in_plugins_dir(name)
    if exe_file:
        return exe_file
    if System.macos and fsboot.is_frozen():
        exe_file = find_executable_in_side_by_side_app_bundle(name)
        if exe_file:
            return exe_file
    exe_file = find_executable_side_by_side(name)
    if exe_file:
        return exe_file
    exe_file = find_executable_in_side_by_side_plugin(name)
    if exe_file:
        return exe_file
    return None
 def find_executable(self, name):
     logger.debug("PluginManager.find_executable %s", repr(name))
     if fsboot.development():
         executable = self.find_executable_development(name)
         if executable:
             return executable
     try:
         plugin = self.provides()["executable:" + name]
     except KeyError:
         # Did not find executable in plugin, try to find executable
         # bundled with the program.
         if System.windows:
             exe_name = name + ".exe"
         else:
             exe_name = name
         path = os.path.join(fsboot.executable_dir(), exe_name)
         logger.debug("Checking %s", path)
         if os.path.exists(path):
             logger.debug("Found non-plugin executable %s", path)
             return Executable(path)
         return None
     return plugin.executable(name)