Exemple #1
0
    def _updatePictureSource(self, subFolderDir: str):
        picturesPath = os.path.join(
            subFolderDir,
            cfgValue[CfgKey.DIASHOW_CLIENT_PICTURE_SOURCE_FOLDER])
        framePath = os.path.join(
            subFolderDir,
            cfgValue[CfgKey.DIASHOW_CLIENT_PICTURE_FRAME_PICTURE])
        if not FileFolderService.existFile(framePath):
            framePath = None
        pictureConfig = PicturesConfig(subFolderDir)

        if pictureConfig.get(PicturesConfig.DEFAULT) == "True":
            self.pictures.addDefault(
                self._getPicturesByPath(picturesPath, pictureConfig,
                                        framePath))
        elif pictureConfig.get(PicturesConfig.FROM_SERVER) == "True":
            if self.withoutServer:
                FileFolderService.removeIfExist(picturesPath)
            else:
                self._loadPicturesFromServer(picturesPath)
                self.pictures.add(
                    self._getPicturesByPath(picturesPath, pictureConfig,
                                            framePath))
        elif FileFolderService.existFolder(picturesPath):
            self.pictures.add(
                self._getPicturesByPath(picturesPath, pictureConfig,
                                        framePath))
Exemple #2
0
 def find(self, key:CfgKey):
     if FileFolderService.existFile(self.propertiesPath):
         fileLines = FileFolderService.readFile(self.propertiesPath)
         keyValuePairs = self._getPropertiesAsDict(fileLines)
         if key._name_ in keyValuePairs:
             return keyValuePairs[key._name_]
     return None
Exemple #3
0
 def __init__(self, folderPath):
     configFilePath = os.path.join(
         folderPath, cfgValue[CfgKey.DIASHOW_CLIENT_PICTURE_CONFIG_FILE])
     self.config = {}
     if FileFolderService.existFile(configFilePath):
         fileLines = FileFolderService.readFile(configFilePath)
         self.config = {}
         for fileLine in fileLines:
             fileLineParts = fileLine.split("=", 1)
             self.config[fileLineParts[0].replace(
                 '=', '').strip()] = fileLineParts[1].strip()
    def _getUnicFileName(filePath: str):
        nameWithExtension = os.path.basename(filePath)
        name = os.path.splitext(nameWithExtension)[0]
        extension = os.path.splitext(nameWithExtension)[1]
        dir = ntpath.dirname(filePath)

        while True:
            randomNumber = random.randint(1000, 9999)
            newFilePath = os.path.join(
                dir, name + "_" + str(randomNumber) + extension)
            if not FileFolderService.existFile(newFilePath):
                return newFilePath
Exemple #5
0
 def _checkImageExist(self, id: str, path: str):
     if (FileFolderService.existFile(path)):
         return True
     else:
         self._deletById(id)
         return False
Exemple #6
0
 def set(self, key:CfgKey, value):
     keyValuePairs = {}
     if FileFolderService.existFile(self.propertiesPath):
         fileLines = FileFolderService.readFile(self.propertiesPath)
         keyValuePairs = self._getPropertiesAsDict(fileLines)
     self._saveProperty(keyValuePairs, key, value)