Esempio n. 1
0
    def confirm_skin_path(self, xml_file):
        """
        Confirms xml_file for window exists and retuns a tuple for path data, if xml file does not exist, reverts to
        base theme window xml
        :param xml_file: Name of window xml_file
        :type xml_file: str
        :return: Typle (xml file name, xml file path)
        :rtype: tuple
        """
        if self._active_skin_path == g.ADDON_PATH:
            return xml_file, self._active_skin_path

        skins_folder = os.path.join(
            self._active_skin_path, "resources", "skins", "Default"
        )

        tools.makedirs(skins_folder, exist_ok=True)

        for folder in [
            folder
            for folder in os.listdir(skins_folder)
            if folder and os.path.isdir(os.path.join(skins_folder, folder))
        ]:
            if folder == "media":
                continue
            if xml_file in os.listdir(os.path.join(skins_folder, folder)):
                return xml_file, self._active_skin_path

        return xml_file, g.ADDON_PATH
Esempio n. 2
0
        def translatePath(path):
            """Returns the translated path"""
            valid_dirs = [
                "xbmc",
                "home",
                "temp",
                "masterprofile",
                "profile",
                "subtitles",
                "userdata",
                "database",
                "thumbnails",
                "recordings",
                "screenshots",
                "musicplaylists",
                "videoplaylists",
                "cdrips",
                "skin",
            ]

            if not path.startswith("special://"):
                return path
            parts = path.split("/")[2:]
            assert len(parts) > 1, "Need at least a single root directory"

            name = parts[0]
            assert name in valid_dirs, "{} is not a valid root dir.".format(
                name)

            parts.pop(0)  # remove name property

            dir_master = os.path.join(MOCK.PROFILE_ROOT, "userdata")

            tools.makedirs(dir_master, exist_ok=True)

            if name == "xbmc":
                return os.path.join(MOCK.XBMC_ROOT, *parts)
            elif name in ("home", "logpath"):
                if not MOCK.RUN_AGAINST_INSTALLATION and all(
                        x in parts for x in ["addons", "plugin.video.seren"]):
                    return MOCK.PROFILE_ROOT
                return os.path.join(MOCK.PROFILE_ROOT, *parts)
            elif name in ("masterprofile", "profile"):
                return os.path.join(dir_master, *parts)
            elif name == "database":
                return os.path.join(dir_master, "Database", *parts)
            elif name == "thumbnails":
                return os.path.join(dir_master, "Thumbnails", *parts)
            elif name == "musicplaylists":
                return os.path.join(dir_master, "playlists", "music", *parts)
            elif name == "videoplaylists":
                return os.path.join(dir_master, "playlists", "video", *parts)
            else:
                import tempfile

                tempdir = os.path.join(tempfile.gettempdir(), "XBMC", name)
                tools.makedirs(tempdir, exist_ok=True)
                return os.path.join(tempdir, *parts)
Esempio n. 3
0
    def deploy_init():
        folders = ["providerModules/", "providers/"]
        root_init_path = os.path.join(g.ADDON_USERDATA_PATH, "__init__ .py")

        if not xbmcvfs.exists(g.ADDON_USERDATA_PATH):
            tools.makedirs(g.ADDON_USERDATA_PATH, exist_ok=True)
        if not xbmcvfs.exists(root_init_path):
            xbmcvfs.File(root_init_path, "a").close()
        for i in folders:
            folder_path = os.path.join(g.ADDON_USERDATA_PATH, i)
            tools.makedirs(folder_path, exist_ok=True)
            xbmcvfs.File(os.path.join(folder_path, "__init__.py"), "a").close()
        provider_init = xbmcvfs.File(
            os.path.join(g.ADDON_USERDATA_PATH, "providers", "__init__.py"),
            "w+")
        provider_init.write(str(base64.b64decode(INIT_BASE64).decode("utf-8")))
        provider_init.close()
Esempio n. 4
0
 def __init__(self):
     self.base_path = os.path.abspath(
         os.path.join(os.path.dirname(__file__), ".."))
     self.artifact_path = os.path.join(self.base_path, "artifact")
     tools.makedirs(self.artifact_path, exist_ok=True)