def mode(cls) -> Mode:
     if fsboot.is_frozen():
         return cls.Mode.FROZEN
     elif os.path.exists(
             os.path.join(Application.executable_dir(), "pyproject.toml")):
         return cls.Mode.DEVELOPMENT
     return cls.Mode.INSTALLED
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 data_dirs(self):
        data_dirs = []
        # base_dirs = []

        # if len(sys.argv) > 0:
        #     script_dir = os.path.dirname(sys.argv[0])
        #     base_dirs.append(os.path.join(script_dir, "share"))

        if fsboot.is_frozen():
            if System.macos:
                data_dirs.append(
                    os.path.normpath(
                        os.path.join(self.executable_dir(), "..", "Resources",
                                     "Data")))
            else:
                data_dirs.append(self.executable_dir())

            # FIXME: Plugin/Data directory as well
        else:
            data_dirs.append(
                os.path.normpath(
                    os.path.join(self.executable_dir(), "..", "share",
                                 self.name)))

        # data_dirs.append(self.executable_dir())
        # if System.windows:
        #     base_dirs.append(os.path.join(self.executable_dir(), "share"))
        # elif System.macos:
        #     base_dirs.append(
        #         os.path.join(self.executable_dir(), "..", "Resources", "Data")
        #     )
        # else:
        # FIXME: $XDG_DATA_DIRS, $XDG_DATA_HOME
        # for dir_name in base_dirs:
        #     data_dir = os.path.join(dir_name, self.name)
        #     logger.debug("* checking for data dir %s", data_dir)
        #     if os.path.exists(data_dir):
        #         data_dirs.append(data_dir)
        # self._data_dirs = data_dirs
        # logger.debug("data dirs: %s", repr(data_dirs))
        return data_dirs
Exemplo n.º 4
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
Exemplo n.º 5
0
def setup_frozen_qpa_platform_plugin_path():
    if not fsboot.is_frozen():
        return