def GetSystemTmpPath() -> cPath:
    """ Gets the path to the tmp folder """
    oPath: cPath

    oPath = cPath(GetEnvVar(u"TMP"))
    if oPath.Exists():
        return oPath

    oPath = OS_GetSystemUserPath() + "\\AppData\\Local\\Temp"
    if oPath.Exists():
        return oPath

    oPath = Globals.oPathUserDownload + "orcatmp"

    oPath.Create()
    return oPath
Exemple #2
0
    def CreateLogoSources(self, **kwargs) -> None:
        aSourceIcons: List[str]
        dFolderTarget: Dict[str, str] = {}
        oFnDest: cFileName
        oFnSource: cFileName
        oFnTarFile: cFileName
        oPathDest: cPath
        oPathDestRef: cPath
        oPathDestSub: cPath
        uFileCore: str
        uFile: str
        uFnSource: str
        uPathSource: str
        uSubFolder: str
        oPathSources: cPath
        oPathSourcesDebug: cPath
        aFolder: List[str]
        aFiles: List[str]

        oPathSources = cPath("$var(RESOURCEPATH)/tvlogos-src")
        oPathSourcesDebug = cPath("c:/tvlogos-src")
        if oPathSourcesDebug.Exists():
            oPathSources = oPathSourcesDebug

        oPathSourcesDebug = OS_GetSystemUserPath() + "tvlogos-src"
        if oPathSourcesDebug.Exists():
            oPathSources = oPathSourcesDebug

        aFiles = oPathSources.GetFileList(bSubDirs=False, bFullPath=True)
        if aFiles:
            oFnSource = cFileName(oPathSources) + "srp.index.txt"
            if not oFnSource.Exists():
                ShowErrorPopUp(
                    uMessage="srp.index.txt is missing in source folder!")
                return
            oPathSourcesDebug = OS_GetSystemTmpPath() + "tvlogos-src"
            oPathSourcesDebug.Delete()
            oPathSourcesDebug.Create()
            oFnSource.Copy(oNewFile=oPathSourcesDebug)
            for uFnXY in aFiles:
                if uFnXY.endswith(
                        ".tar.xz"
                ) and "snp-full" in uFnXY and "190x102." in uFnXY:
                    oTarFile = cTarFile().ImportFullPath(uFnFullName=uFnXY)
                    self.ShowDebug(uMsg="Untar: %s to %s" %
                                   (oTarFile.string, oPathSourcesDebug.string))
                    oTarFile.UnTar(oPath=oPathSourcesDebug)
            oPathSources = oPathSourcesDebug

        aFolder = oPathSources.GetFolderList(bFullPath=True)
        for uPathSource in aFolder:
            dFolderTarget.clear()
            uFileCore = uPathSource[uPathSource.rfind("102.") +
                                    4:uPathSource.find("_")]
            oPathDest = Globals.oPathTVLogos + uFileCore
            oPathDest.Create()

            self.ShowDebug(uMsg="Create Picons for: %s" % (oPathDest.string))

            oFnSource = cFileName(oPathSources) + "srp.index.txt"

            if not oFnSource.Exists():
                ShowErrorPopUp(
                    uMessage="srp.index.txt is missing in source folder!")
                return

            oFnSource.Copy(oNewFile=oPathDest)

            oPathDest = oPathDest + "picons"
            oPathDest.Create()
            oPathDestRef = oPathDest + "references"
            oPathDestRef.Create()
            aSourceIcons = cPath(uPathSource).GetFileList(bFullPath=False,
                                                          bSubDirs=False)
            for uFnSource in aSourceIcons:
                oFnSource = cFileName(cPath(uPathSource)) + uFnSource
                if uFnSource.startswith("1_"):
                    oFnSource.Copy(oNewFile=oPathDestRef)
                else:
                    uSubFolder = uFnSource.upper()[:2]
                    uSubFolder = uSubFolder.replace(".", "")
                    if uSubFolder[0].isnumeric():
                        uSubFolder = "0-9"
                    oPathDestSub = oPathDest + uSubFolder
                    if not uSubFolder in dFolderTarget:
                        dFolderTarget[uSubFolder] = uSubFolder
                        oPathDestSub.Create()
                    oFnSource.Copy(oNewFile=oPathDestSub)