Ejemplo n.º 1
0
 def plugin_path(cls):
     result = []
     plugins_dir = FSGSDirectories.get_plugins_dir()
     if plugins_dir and os.path.isdir(plugins_dir):
         result.append(plugins_dir)
     expansion_dir = os.path.join(
         FSGSDirectories.get_base_dir(), "Workspace", "Expansion"
     )
     if expansion_dir and os.path.isdir(expansion_dir):
         result.append(expansion_dir)
     if System.macos:
         system_plugins_dir = os.path.join(
             fsboot.executable_dir(),
             "..",
             "..",
             "..",
             "..",
             "..",
             "..",
             "Plugins",
         )
     else:
         system_plugins_dir = os.path.join(
             fsboot.executable_dir(), "..", "..", "..", "Plugins"
         )
     if os.path.isdir(system_plugins_dir):
         result.append(system_plugins_dir)
     return result
Ejemplo n.º 2
0
def init_qt():
    if sys.platform == "darwin":
        # qt_plugins_dir = os.path.join(
        #     BaseApplication.executable_dir(), "..", "Resources",
        #     "qt_plugins")
        # print(qt_plugins_dir)
        # if os.path.exists(qt_plugins_dir):
        #     QApplication.setLibraryPaths([qt_plugins_dir])
        if os.path.exists(
                os.path.join(fsboot.executable_dir(), "platforms",
                             "libqcocoa.dylib")):
            # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
            QApplication.setLibraryPaths([fsboot.executable_dir()])

    if getattr(sys, "frozen", False):
        # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
        QApplication.setLibraryPaths([fsboot.executable_dir()])

    # Should not be necessary with Qt 5.2.x:
    # fix_qt_for_maverick()

    fsbc.desktop.set_open_url_in_browser_function(open_url_in_browser)
    qapplication = QtBaseApplication(sys.argv)
    initialize_qt_style(qapplication)
    return qapplication
Ejemplo n.º 3
0
def init_qt():
    if sys.platform == "darwin":
        # qt_plugins_dir = os.path.join(
        #     BaseApplication.executable_dir(), "..", "Resources",
        #     "qt_plugins")
        # print(qt_plugins_dir)
        # if os.path.exists(qt_plugins_dir):
        #     QApplication.setLibraryPaths([qt_plugins_dir])
        if os.path.exists(
            os.path.join(
                fsboot.executable_dir(), "platforms", "libqcocoa.dylib"
            )
        ):
            # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
            QApplication.setLibraryPaths([fsboot.executable_dir()])

    if getattr(sys, "frozen", False):
        if sys.platform == "darwin":
            # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
            QApplication.setLibraryPaths(
                [os.path.join(fsboot.executable_dir(), "..", "PlugIns")]
            )
        else:
            # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
            QApplication.setLibraryPaths([fsboot.executable_dir()])

    # Should not be necessary with Qt 5.2.x:
    # fix_qt_for_maverick()

    fsbc.desktop.set_open_url_in_browser_function(open_url_in_browser)
    qapplication = QtBaseApplication([])
    initialize_qt_style(qapplication)
    return qapplication
Ejemplo n.º 4
0
    def find_emulator_executable(self, name):
        # if os.path.isdir("../fs-uae/src"):
        #     # running from source directory, we then want to find locally
        #     # compiled binaries if available
        #     path = "../fs-uae/fs-uae"
        #     if windows:
        #         path += ".exe"
        #     if os.path.isfile(path):
        #         return path
        #     raise Exception("Could not find development FS-UAE executable")

        if "/" in name:
            package, name = name.split("/")
        else:
            package = name

        if windows:
            # first we check if the emulator is bundled inside the launcher
            # directory
            exe = os.path.join(
                fsboot.executable_dir(), package, name + ".exe")
            if not os.path.exists(exe):
                # for when the emulators are placed alongside the launcher /
                # game center directory
                exe = os.path.join(
                    fsboot.executable_dir(), "..", package, name + ".exe")
            if not os.path.exists(exe):
                # when the emulators are placed alongside the fs-uae/ directory
                # containing launcher/, for FS-UAE Launcher & FS-UAE Arcade
                exe = os.path.join(
                    fsboot.executable_dir(), "..", "..", package, name + ".exe")
            if not os.path.exists(exe):
                return None
            return exe
        elif macosx:
            exe = os.path.join(
                fsboot.executable_dir(), "..",
                package + ".app", "Contents", "MacOS", name)
            if not os.path.exists(exe):
                exe = os.path.join(
                    fsboot.executable_dir(), "..", "..", "..",
                    package + ".app", "Contents", "MacOS", name)
            if not os.path.exists(exe):
                exe = os.path.join(
                    "/Applications",
                    package + ".app", "Contents", "MacOS", name)
            if not os.path.exists(exe):
                return None
            return exe

        if os.path.exists("/opt/{0}/bin/{1}".format(package, name)):
            return "/opt/{0}/bin/{1}".format(package, name)

        if package == name:
            for dir in os.environ["PATH"].split(":"):
                # dir = unicode_path(dir)
                path = os.path.join(dir, name)
                if os.path.exists(path):
                    return path
        return None
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
    def find_emulator_executable(self, name):
        # if os.path.isdir("../fs-uae/src"):
        #     # running from source directory, we then want to find locally
        #     # compiled binaries if available
        #     path = "../fs-uae/fs-uae"
        #     if windows:
        #         path += ".exe"
        #     if os.path.isfile(path):
        #         return path
        #     raise Exception("Could not find development FS-UAE executable")

        if "/" in name:
            package, name = name.split("/")
        else:
            package = name

        if windows:
            # first we check if the emulator is bundled inside the launcher
            # directory
            exe = os.path.join(
                fsboot.executable_dir(), package, name + ".exe")
            if not os.path.exists(exe):
                # for when the emulators are placed alongside the launcher /
                # game center directory
                exe = os.path.join(
                    fsboot.executable_dir(), "..", package, name + ".exe")
            if not os.path.exists(exe):
                # when the emulators are placed alongside the fs-uae/ directory
                # containing launcher/, for FS-UAE Launcher & FS-UAE Arcade
                exe = os.path.join(
                    fsboot.executable_dir(), "..", "..", package, name + ".exe")
            if not os.path.exists(exe):
                return None
            return exe
        elif macosx:
            exe = os.path.join(
                fsboot.executable_dir(), "..",
                package + ".app", "Contents", "MacOS", name)
            if not os.path.exists(exe):
                exe = os.path.join(
                    fsboot.executable_dir(), "..", "..", "..",
                    package + ".app", "Contents", "MacOS", name)
            if not os.path.exists(exe):
                exe = os.path.join(
                    "/Applications",
                    package + ".app", "Contents", "MacOS", name)
            if not os.path.exists(exe):
                return None
            return exe

        if os.path.exists("/opt/{0}/bin/{1}".format(package, name)):
            return "/opt/{0}/bin/{1}".format(package, name)

        if package == name:
            for directory in os.environ["PATH"].split(":"):
                path = os.path.join(directory, name)
                if os.path.exists(path):
                    return path
        return None
Ejemplo n.º 8
0
 def find_libretro_shader_development(self, relative_path):
     path = os.path.join(fsboot.executable_dir(), "..", "retroarch",
                         relative_path)
     # Try one additional level up
     if not os.path.exists(path):
         path = os.path.join(fsboot.executable_dir(), "..", "..",
                             "retroarch", relative_path)
         # logger.debug("Checking %s", path)
     if os.path.exists(path):
         # logger.debug("Found non-plugin library %s", path)
         return path
     return None
Ejemplo n.º 9
0
 def find_libretro_core_development(self, name):
     # FIXME: Move to pluginmanager?
     # See if we can find the core in a project dir side by side
     name = name + "_libretro"
     dll_name = name + ".so"
     path = os.path.join(fsboot.executable_dir(), "..", name, dll_name)
     # logger.debug("Checking %s", path)
     # Try one additional level up
     if not os.path.exists(path):
         path = os.path.join(fsboot.executable_dir(), "..", "..", name,
                             dll_name)
         # logger.debug("Checking %s", path)
     if os.path.exists(path):
         # logger.debug("Found non-plugin library %s", path)
         return path
     return None
    def find_executable_development(self, name):
        if System.windows:
            exe_name = name + ".exe"
        else:
            exe_name = name
        if name == "x64sc-fs":
            logger.debug("Lookup hack for vice-fs/x64sc-fs")
            name = "vice-fs"
        # if os.path.basename(os.getcwd()) == "fs-uae-launcher-private":
        #     if name == "fs-uae":
        #         name = "fs-uae-private"
        if os.path.basename(os.getcwd()).endswith("-private"):
            dir_name = name + "-private"
        else:
            dir_name = name

        # See if we can find the executable in a project dir side by side
        path = os.path.join(fsboot.executable_dir(), "..", dir_name, exe_name)
        logger.debug("Checking %s", path)
        # Try one additional level up
        # if not os.path.exists(path):
        #     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)
            # We want to be able to load bundled libraries from the
            # development directory, before the emulator has been
            # standalone-ified.
            return Executable(path, ld_library_path=True)
        return None
Ejemplo n.º 11
0
    def load_plugins(self):
        plugin_path = self.plugin_path()
        print("[PLUGINS] Executable dir:", fsboot.executable_dir())
        print("[PLUGINS] Path:", plugin_path)
        print("[PLUGINS] Machine:", platform.machine().lower())
        print("[PLUGINS] Architecture:", platform.architecture()[0])
        print("[PLUGINS] Plugin OS/arch:", Plugin.os_name(True),
              Plugin.arch_name(True))

        for dir_path in plugin_path:
            # if not os.path.isdir(dir_path):
            #     continue
            for name in os.listdir(dir_path):
                plugin_dir = os.path.join(dir_path, name)
                if not os.path.isdir(plugin_dir):
                    continue
                try:
                    plugin = self.load_plugin(plugin_dir)
                except Exception:
                    traceback.print_exc()
                    continue
                if plugin is None:
                    continue
                self._plugins.append(plugin)
                self._plugins_map[plugin.name] = plugin
            self._plugins.sort(key=attrgetter("name"))
Ejemplo n.º 12
0
    def load_plugins(self):
        plugin_path = self.plugin_path()
        logger.info("Executable dir: %s", fsboot.executable_dir())
        logger.info("Path: %s", plugin_path)
        logger.info("Machine: %s", platform.machine().lower())
        logger.info("Architecture: %s", platform.architecture()[0])
        logger.info(
            "Plugin OS/arch: %s/%s",
            Plugin.os_name(True),
            Plugin.arch_name(True),
        )

        for dir_path in plugin_path:
            # if not os.path.isdir(dir_path):
            #     continue
            for name in os.listdir(dir_path):
                plugin_dir = os.path.join(dir_path, name)
                if not os.path.isdir(plugin_dir):
                    continue
                try:
                    plugin = self.load_plugin(plugin_dir)
                except Exception:
                    traceback.print_exc()
                    continue
                if plugin is None:
                    continue
                self._plugins.append(plugin)
                self._plugins_map[plugin.name] = plugin
            self._plugins.sort(key=attrgetter("name"))
    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
Ejemplo n.º 14
0
    def plugin_path(cls):
        result = []
        plugins_dir = FSGSDirectories.get_plugins_dir()
        result.append(plugins_dir)

        # Plugins dir location has changed, add several old and new paths here
        # to find plugins in both places (FS-UAE and OpenRetro style).
        plugins_dir = os.path.join(FSGSDirectories.get_base_dir(), "Plugins")
        if plugins_dir not in result:
            result.append(plugins_dir)
        plugins_dir = os.path.join(FSGSDirectories.get_data_dir(), "Plugins")
        if plugins_dir not in result:
            result.append(plugins_dir)

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

        if System.macos:
            system_plugins_dir = os.path.normpath(
                os.path.join(
                    fsboot.executable_dir(),
                    "..",
                    "..",
                    "..",
                    "..",
                    "..",
                    "..",
                    "Plugins",
                ))
            result.append(system_plugins_dir)
        else:
            system_plugins_dir = os.path.normpath(
                os.path.join(fsboot.executable_dir(), "..", "..", "..",
                             "Plugins"))
            result.append(system_plugins_dir)
        # if os.path.isdir(system_plugins_dir):
        #     result.append(system_plugins_dir)

        return result
Ejemplo n.º 15
0
 def plugin_path(cls):
     result = []
     plugins_dir = FSGSDirectories.get_plugins_dir()
     if plugins_dir and os.path.isdir(plugins_dir):
         result.append(plugins_dir)
     expansion_dir = os.path.join(FSGSDirectories.get_base_dir(),
                                  "Workspace", "Expansion")
     if expansion_dir and os.path.isdir(expansion_dir):
         result.append(expansion_dir)
     if System.macos:
         system_plugins_dir = os.path.join(fsboot.executable_dir(), "..",
                                           "..", "..", "..", "..", "..",
                                           "Plugins")
     else:
         system_plugins_dir = os.path.join(fsboot.executable_dir(), "..",
                                           "..", "..", "Plugins")
     if os.path.isdir(system_plugins_dir):
         result.append(system_plugins_dir)
     return result
Ejemplo n.º 16
0
def setup_frozen_requests_ca_cert():
    if not fsboot.is_frozen():
        return
    data_dirs = [fsboot.executable_dir()]
    data_dir = os.path.abspath(
        os.path.join(fsboot.executable_dir(), "..", "..", "Data"))
    debug(data_dir)
    debug(str(os.path.exists(data_dir)))
    if os.path.exists(data_dir):
        data_dirs.append(data_dir)
    else:
        data_dir = os.path.abspath(
            os.path.join(fsboot.executable_dir(), "..", "..", "..", "..", "..",
                         "Data"))
        debug(data_dir)
        debug(str(os.path.exists(data_dir)))
        if os.path.exists(data_dir):
            data_dirs.append(data_dir)
    for data_dir in data_dirs:
        path = os.path.join(data_dir, "cacert.pem")
        if os.path.exists(path):
            debug("[HTTP] Using {}".format(path))
            os.environ["REQUESTS_CA_BUNDLE"] = path
            break
Ejemplo n.º 17
0
 def find_executable_development(self, name):
     if windows:
         exe_name = name + ".exe"
     else:
         exe_name = name
     if name == "x64sc-fs":
         logger.debug("Lookup hack for vice-fs/x64sc-fs")
         name = "vice-fs"
     # See if we can find the executable in a project dir side by side
     path = os.path.join(fsboot.executable_dir(), "..", name, exe_name)
     logger.debug("Checking %s", path)
     # Try one additional level up
     if not os.path.exists(path):
         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)
         # We want to be able to load bundled libraries from the
         # development directory, before the emulator has been
         # standalone-ified.
         return Executable(path, ld_library_path=True)
     return None
Ejemplo n.º 18
0
 def find_library_path(self, name):
     logger.debug("PluginManager.find_library_path %s", repr(name))
     try:
         plugin = self.provides()["library:" + name]
     except KeyError:
         # Did not find module in plugin, try to find module
         # bundled with the program.
         if windows:
             module_name = name + ".dll"
         else:
             module_name = name + ".so"
         path = os.path.join(fsboot.executable_dir(), module_name)
         if os.path.exists(path):
             logger.debug("[PLUGINS] Found non-plugin module %s", path)
             return path
         return None
     return plugin.library_path(name)
Ejemplo n.º 19
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)
         if os.path.exists(path):
             logger.debug("[PLUGINS] Found non-plugin executable %s", path)
             return Executable(path)
         return None
     return plugin.executable(name)
Ejemplo n.º 20
0
 def find_library_path(self, name):
     logger.debug("PluginManager.find_library_path %s", repr(name))
     try:
         plugin = self.provides()["library:" + name]
     except KeyError:
         # Did not find module in plugin, try to find module
         # bundled with the program.
         if windows:
             module_name = name + ".dll"
         else:
             module_name = name + ".so"
         path = os.path.join(fsboot.executable_dir(), module_name)
         if os.path.exists(path):
             logger.debug("Found non-plugin module %s", path)
             return path
         return None
     return plugin.library_path(name)
def find_executable_in_development_project_dir(name: str):
    print("- Find executable in development project dir")
    plugin_name = known_executables.get(name)
    if plugin_name is None:
        return None
    project_dir_name = plugin_name.lower()
    exe_dir = fsboot.executable_dir()
    if exe_dir.endswith("-private"):
        exe_file = path.join(
            exe_dir,
            "..",
            f"{project_dir_name}-private",
            get_exe_name(name),
        )
        if check_executable(exe_file):
            return exe_file
    exe_file = path.join(exe_dir, "..", project_dir_name, get_exe_name(name))
    if check_executable(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)
    def load_plugins(self):
        plugin_path = self.plugin_path()
        logger.info("Executable dir: %s", fsboot.executable_dir())
        logger.info("Path: %s", plugin_path)
        logger.info("Machine: %s", platform.machine().lower())
        logger.info("Architecture: %s", platform.architecture()[0])
        logger.info(
            "Plugin OS/arch: %s/%s",
            Plugin.os_name(True),
            Plugin.arch_name(True),
        )

        # Reversing order so that later loaded plugins (earlier on path)
        # takes precedence.
        # for dir_path in reversed(plugin_path):
        # I guess we should sort the list by version number and only load the
        # newest plugin per name.
        for dir_path in plugin_path:
            if not os.path.isdir(dir_path):
                continue
            # logger.debug(dir_path)
            for name in os.listdir(dir_path):
                plugin_dir = os.path.join(dir_path, name)
                logger.debug(plugin_dir)
                if not os.path.isdir(plugin_dir):
                    continue
                try:
                    plugin = self.load_plugin(plugin_dir)
                except Exception:
                    logger.debug("Could not load %s", plugin_dir)
                    traceback.print_exc()
                    continue
                if plugin is None:
                    logger.debug("No plugin in %s", plugin_dir)
                    continue
                logger.debug("Found plugin in %s", plugin_dir)
                self._plugins.append(plugin)
                self._plugins_map[plugin.name] = plugin
            self._plugins.sort(key=attrgetter("name"))
Ejemplo n.º 24
0
 def executable_dir():
     return fsboot.executable_dir()
Ejemplo n.º 25
0
def initialize_locale(language=None):
    global translations, _initialized
    _initialized = True

    if language is None:
        language = Settings.instance()["language"]

    print("[I18N] Initialize_locale language =", language)
    loc = language
    if not loc:
        try:
            loc, _charset = locale.getdefaultlocale()
            print("[I18N] Locale is", loc)
        except:
            print("[I18N] Exception while checking locale")
            loc = ""
        if not loc:
            loc = ""

    if not loc and sys.platform == "darwin":
        try:
            # noinspection PyUnresolvedReferences
            import CoreFoundation
            c_loc = CoreFoundation.CFLocaleCopyCurrent()
            loc = CoreFoundation.CFLocaleGetIdentifier(c_loc)
        except Exception:
            traceback.print_exc()
        print("[I18N] OS X locale", loc)

    dirs = [
        os.path.join(fsboot.executable_dir(), "share"),
        os.path.join(fsboot.executable_dir(), "..", "share"),
    ]
    if sys.platform == "darwin":
        dirs.insert(
                0, os.path.join(fsboot.executable_dir(), "..", "Resources"))

    locale_base = None
    for dir in dirs:
        check = os.path.join(dir, "fs-uae-launcher", "share-dir")
        print("[I18N] Checking", check)
        if not os.path.exists(check):
            continue
        locale_base = os.path.join(dir, "locale")
        break
    if not locale_base and getattr(sys, "frozen", False):
        locale_base = os.path.abspath(
            os.path.join(
                fsboot.executable_dir(), "..", "..", "Data", "Locale"))

    if locale_base:
        print("[I18N] bindtextdomain fs-uae-launcher:", locale_base)
        gettext_module.bindtextdomain("fs-uae-launcher", locale_base)

    mo_path = None
    if locale_base:
        print("[I18N] find translations for", loc,
              "in local directory", locale_base)
        try:
            mo_path = gettext_module.find(
                    "fs-uae-launcher", locale_base, [loc])
        except Exception as e:
            # a bug in openSUSE 12.2's gettext.py can cause an exception
            # in gettext.find (checking len of None).
            print(repr(e))
    else:
        print("[I18N]  No locale directory found")
    print("[I18N] Path to mo file:", mo_path)

    translations = gettext_module.translation(
            "fs-uae-launcher", locale_base, [loc], fallback=True)
    print("[I18N] Translations object:", translations)
def find_executable_side_by_side(name: str):
    """Find executable side by side, for example in /usr/bin or similar."""
    print("- Find executable side-by-side")
    exe_file = path.join(fsboot.executable_dir(), get_exe_name(name))
    if check_executable(exe_file):
        return exe_file
Ejemplo n.º 27
0
 def executable_dir():
     return fsboot.executable_dir()