Esempio n. 1
0
 def CollectFiles(self,uPath):
     ''' adds all files in a folder to the list of sources '''
     aFiles=GetFileList(uPath,bSubDirs=False,bFullPath=True)
     for uFile in aFiles:
         uFile=AdjustPathToOs(uFile)
         if not uFile in self.aFileList:
             if uFile.endswith(".py") or uFile.endswith(".txt"):
                 self.aFileList.append(uFile)
Esempio n. 2
0
 def NormalizeStream(self,uStream):
     ''' Normalizes the stream name '''
     if not uStream.startswith('rtsp') and uStream.startswith('http'):
         uStream  = AdjustPathToOs(uStream)
     if oORCA.uPlatform!='win':
         # prevent bug in ffmpeg (Android) not able to deal with unicode strings
         # todo: check with later kivy/ffmpeg versions
         uStream=uStream.encode('utf8')
     return uStream
Esempio n. 3
0
 def _validate(self, instance):
     ''' user selected something '''
     if len(instance.selection)==0:
         self._dismiss()
         return
     uValue=AdjustPathToOs(instance.selection[0])
     uValue=uValue.replace(oORCA.uSkinPath,'$var(SKINPATH)')
     uValue=uValue.replace(oORCA.uResourcesPath,'$var(RESOURCEPATH')
     uValue=uValue.replace(oORCA.oDefinitionPathes.uDefinitionPath,'$var(DEFINITIONPATH)')
     uValue=uValue.replace('\\',"/")
     self.value=uValue
     super(SettingFile, self)._validate(instance)
Esempio n. 4
0
    def SaveRepositoryXML(self,uType:str,uDescription:str) -> None:
        """ Saves the main repository directory xml """

        oVal:Element
        uContent:str
        uRoot:str

        oPath:cPath= Globals.oPathTmp + "RepManager"
        oPath.Create()
        oPath=oPath+"repositories"
        oPath.Create()
        oPath=oPath+uType
        oPath.Create()
        oFnXml:cFileName=cFileName(oPath) +'repository.xml'

        oXMLRoot:Element    = Element('repository')
        oVal                = SubElement(oXMLRoot,'version')
        oVal.text           = '1.00'
        oVal                = SubElement(oXMLRoot,'type')
        oVal.text           = uType
        oVal                = SubElement(oXMLRoot,'description')
        oVal.text           = uDescription

        oXMLEntries:Element = SubElement(oXMLRoot,'entries')

        for oEntry in self.aRepManagerEntries:
            Logger.debug ('Saving Repository-Entry [%s]' % oEntry.oFnEntry.string)

            oEntry.oRepEntry.WriteToXMLNode(oXMLNode=oXMLEntries)
            for oSource in oEntry.oRepEntry.aSources:
                bZipParentDir:bool = cPath.CheckIsDir(uCheckName=oSource.uLocal)
                # Create according Zip
                if bZipParentDir:
                    uUpper:str          = os.path.basename(oSource.uSourceFile)
                    uFinalPath:str      = uType
                    oDest:cFileName     = cFileName().ImportFullPath(uFnFullName='%s/RepManager/repositories/%s/%s' % (Globals.oPathTmp.string, uFinalPath, uUpper))
                    uUpper1:str         = os.path.split(os.path.abspath(oSource.uLocal))[0]
                    uRoot           = AdjustPathToOs(uPath=ReplaceVars(uUpper1)+'/')
                    self.aZipFiles.append({'filename':oSource.uLocal,'dstfilename':oDest.string, 'removepath':uRoot, 'skipfiles':ToUnicode(oEntry.oRepEntry.aSkipFileNames)})
                else:
                    uDest:str = AdjustPathToOs(uPath='%s/RepManager/repositories/%s/%s.zip' % (Globals.oPathTmp.string, uType, os.path.splitext(os.path.basename(oSource.uLocal))[0]))
                    uRoot = AdjustPathToOs(uPath=Globals.oPathRoot.string + "/" + oSource.uTargetPath)
                    self.aZipFiles.append({'filename':oSource.uLocal,'dstfilename':uDest, 'removepath':uRoot})

        oFSFile     = open(oFnXml.string, 'w')
        uContent    = XMLPrettify(oElem=oXMLRoot)
        uContent    = ReplaceVars(uContent)
        oFSFile.write(EscapeUnicode(uContent))
        oFSFile.close()
Esempio n. 5
0
def CleanUp(*,uFinal:str) -> str:
    while "//" in uFinal:
        uFinal = uFinal.replace("//", "/")
    while "\\\\" in uFinal:
        uFinal = uFinal.replace("\\\\", "\\")

    return AdjustPathToOs(uPath=ReplaceVars(uFinal))
Esempio n. 6
0
    def GetFileList(self,*,bSubDirs:bool=False, bFullPath:bool=False) -> List:
        """
        Returns a dict of all files in a folder

        :param bool bSubDirs: If true, includes files in folders
        :param bool bFullPath: If True, the file entries include the full folder struture, otherwise on the filename is returned
        :return: A list of all files
        """

        oDirList:List = []
        uRootDir:str = self.string
        uItem:str
        try:
            for uItem in listdir(uRootDir):
                if not isdir(join(uRootDir, uItem)):
                    if not bFullPath:
                        oDirList.append(uItem)
                    else:
                        oDirList.append(AdjustPathToOs(uPath=uRootDir + '/' + uItem))
                else:
                    if bSubDirs:
                        oDirList.extend((cPath(uRootDir) + uItem).GetFileList(bSubDirs= bSubDirs,bFullPath=bFullPath))
        except Exception as e:
            Logger.debug(u'can\'t get File list:' + ToUnicode(str(e)) + " :" + uRootDir)

        return oDirList
Esempio n. 7
0
    def GetFolderList(self,*,bFullPath:bool=False) -> List:
        """
        Returns a list of all folders in a path

        :param bool bFullPath: If True, the folder entries include the full folder struture, otherwise on the foldername is returned
        :return: A list of all folder in a folder
        """

        oDirList:List = []
        uRootDir:str = u''
        uItem:str
        try:

            # stdout_encoding = sys.getfilesystemencoding()
            # print 'stdout_encoding:', stdout_encoding
            uRootDir = CleanUp(uFinal=self.string)
            for uItem in listdir(uRootDir):
                if isdir(join(uRootDir, uItem)):
                    if not bFullPath:
                        oDirList.append(uItem)
                    else:
                        oDirList.append(AdjustPathToOs(uPath=uRootDir + '/' + uItem))
        except Exception as e:
            Logger.warning(u'can\'t get Dirlist ' + ToUnicode(e) + " " + uRootDir)
        return oDirList
Esempio n. 8
0
    def GetFileList(self, bSubDirs=False, bFullPath=False):
        """
        Returns a dict of all files in a folder

        :rtype: list
        :param bool bSubDirs: If true, includes files in folders
        :param bool bFullPath: If True, the file entries include the full folder struture, otherwise on the filename is returned
        :return: A list of all files
        """

        oDirList = []
        try:
            uRootDir = self.string
            for oItem in listdir(uRootDir):
                if not isdir(join(uRootDir, oItem)):
                    if not bFullPath:
                        oDirList.append(oItem)
                    else:
                        oDirList.append(AdjustPathToOs(uRootDir + '/' + oItem))
                else:
                    if bSubDirs:
                        oDirList.extend((cPath(uRootDir) + oItem).GetFileList(
                            bSubDirs, bFullPath))
        except Exception as e:
            uMsg = u'can\'t get File list:' + ToUnicode(e) + " :" + uRootDir
            Logger.warning(uMsg)

        return oDirList
Esempio n. 9
0
 def ParseFromXMLNode(self, *, oXMLNode: Element) -> None:
     """ Parses an xms string into object vars """
     self.uSourceFile = GetXMLTextValue(oXMLNode=oXMLNode,
                                        uTag=u'sourcefile',
                                        bMandatory=True,
                                        vDefault=u'')
     self.uTargetPath = GetXMLTextValue(oXMLNode=oXMLNode,
                                        uTag=u'targetpath',
                                        bMandatory=True,
                                        vDefault=u'')
     self.uLocal = AdjustPathToOs(uPath=ReplaceVars(
         GetXMLTextValue(oXMLNode=oXMLNode,
                         uTag=u'local',
                         bMandatory=False,
                         vDefault=u'')))
Esempio n. 10
0
 def ParseFromXMLNode(self, *, oXMLNode: Element) -> None:
     """ Parses an xms string into object vars """
     self.uFile: str = AdjustPathToOs(uPath=oXMLNode.text)
Esempio n. 11
0
def CleanUp(uFinal):
    while "//" in uFinal:
        uFinal = uFinal.replace("//", "/")
    while "\\\\" in uFinal:
        uFinal = uFinal.replace("\\\\", "\\")
    return AdjustPathToOs(ReplaceVars(uFinal))
Esempio n. 12
0
 def ParseFromXMLNode(self, oXMLNode):
     """ Parses an xms string into object vars """
     self.uFile = AdjustPathToOs(oXMLNode.text)
Esempio n. 13
0
 def ParseFromXMLNode(self, oXMLNode):
     """ Parses an xms string into object vars """
     self.uSourceFile = GetXMLTextValue(oXMLNode, u'sourcefile', True, u'')
     self.uTargetPath = GetXMLTextValue(oXMLNode, u'targetpath', True, u'')
     self.uLocal = AdjustPathToOs(
         ReplaceVars(GetXMLTextValue(oXMLNode, u'local', False, u'')))