Esempio n. 1
0
 def getTempPicturePath():
     folder = os.path.join(ShottedPictureService._getSaveFolder(),
                           CfgService.get(CfgKey.RAW_PICTURE_SUB_DIR))
     FileFolderService.createFolderIfNotExist(folder)
     relativPath = os.path.join(
         folder, "temp" + CfgService.get(CfgKey.PICTURE_FORMAT))
     return FileFolderService.getAbsoltPath(relativPath)
 def loadDefaultBackgrounds(self):
     # Bilder aus Ordner laden
     folderPath = self._getBackgroundPathCreateFolderIfNotExtist()
     picturePaths = FileFolderService.getFolderContentPictures(folderPath)
     FileFolderService.removeIfExist(self._getTempPath())
     FileFolderService.createFolderIfNotExist(self._getTempPath())
     backgrounds = []
     for picturePath in picturePaths:
         backgrounds.append(self._loadBackgroundImages(picturePath,False))
     self.globalVariable.setDefaultBackground(backgrounds)
Esempio n. 3
0
    def run(self):
        numberUrls = len(self.urls)
        FileFolderService.createFolderIfNotExist(self.targetFolder)
        for index, url in enumerate(self.urls):
            if (self.downloadSuccessFile != None
                    and FileFolderService.containsLineInFile(
                        url, self.downloadSuccessFile)):
                continue
            request = self.getRequest(url)
            if request == None:
                self.setProgress(index, numberUrls)
                continue

            self.savePicture(request, self.getContentFileType(request, url),
                             index, self.targetFolder)
            self.setProgress(index, numberUrls)
            if self.downloadSuccessFile != None:
                FileFolderService.writeLineInFile(True,
                                                  self.downloadSuccessFile,
                                                  url)

        self.setProgress(numberUrls, numberUrls)
    def getCustomFilePathWithName(customBackgroundFolder:str,uuid:str, fileName:str = None):
        FileFolderService.createFolderIfNotExist(customBackgroundFolder)
        newFileName = uuid

        existingFileNames = []
        for fileUrl in FileFolderService.getFolderContentFiles(customBackgroundFolder):
            existingFileName = FileFolderService.getFileName(fileUrl)
            if existingFileName.startswith( newFileName ):
                existingFileNames.append(fileUrl)

        if fileName is None:
            if len(existingFileNames)> 0:
                newFileNameWithIndex = newFileName+"_"+str(len(existingFileNames))
                for existingFileUrl in existingFileNames:
                    existingFileName = FileFolderService.getFileName(existingFileUrl)
                    if existingFileName.startswith(newFileNameWithIndex):
                        return existingFileUrl


            return None
        else:
            type = FileFolderService.getFileType(fileName)
            return os.path.join(customBackgroundFolder,newFileName+"_"+str(len(existingFileNames)+1)+type)
 def _getBackgroundPathCreateFolderIfNotExtist(self):
     folder = GreenscreenBackgroundService.getDefaultBackgroundPath()
     FileFolderService.createFolderIfNotExist(folder)
     return folder