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))
def uploadBackground_image(): uuid = request.form.get('uuid') if uuid is None: abort(404) authorizade = ServerDbSevice.getBackgroundUploadAuthorization(uuid) if authorizade is None: abort(404) if 'file' not in request.files: flash(textValue[TextKey.WEB_UPLOAD_BACKGROUND_ERROR_NO_PICTURE_SELECTED]) return redirect(request.url+"/"+uuid) file = request.files['file'] if file.filename == '': flash(textValue[TextKey.WEB_UPLOAD_BACKGROUND_ERROR_NO_PICTURE_SELECTED]) return redirect(request.url+"/"+uuid) if file and allowed_background_file(file.filename): if authorizade["cleanBefore"]: FileFolderService.removeIfExist(authorizade["targetPath"]) filename = secure_filename(file.filename) filePath = GreenscreenBackgroundService.getCustomFilePathWithName(authorizade["targetPath"],uuid, filename) file.save(filePath) flash(textValue[TextKey.WEB_UPLOAD_BACKGROUND_SUCCESS]) if authorizade["cleanBefore"]: flash(textValue[TextKey.WEB_UPLOAD_BACKGROUND_SUCCESS_HINT_CUSTOMBACKGROUND]) else: flash(textValue[TextKey.WEB_UPLOAD_BACKGROUND_SUCCESS_HINT_DEFAULTBACKGROUND]) return render_template(UPLOAD_BACKGROUND_HTML_PATH,uuid=uuid,url = request.url,pictureUrl=CfgService.get(CfgKey.SERVER_DISPLAY_UPLOAD_PICTURE)+'/'+uuid+"/"+str(hash(filePath))) else: flash(textValue[TextKey.WEB_UPLOAD_BACKGROUND_ERROR_WRONG_TYPE]) return redirect(request.url+"/"+uuid)
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)
def deleteLoadingGifFolder(self): self.disableAllButtons() FileFolderService.removeIfExist( CfgService.get(CfgKey.PAGE_CAPTUREPHOTO_LOADING_GIF_FOLDER)) FileFolderService.removeIfExist( CfgService.get( CfgKey. PAGE_SYSTEMPICTUREMANAGER_LOADINGGIFS_PICTURE_SOURCE_SUCCESS_DOWNLOAD )) self.enableAllButtons() self.loadingGifDeleteButton.setText( textValue[TextKey.PAGE_SYSTEMPICTUREMANAGER_SUCCESSFULL])
def deleteFunnyPictureFolder(self): self.disableAllButtons() FileFolderService.removeIfExist( CfgService.get(CfgKey.PAGE_CAPTUREPHOTO_LAST_IMAGE_FOLDER)) FileFolderService.removeIfExist( CfgService.get( CfgKey. PAGE_SYSTEMPICTUREMANAGER_FUNNY_PICTURE_SOURCE_SUCCESS_DOWNLOAD )) self.enableAllButtons() self.funnyDeleteButton.setText( textValue[TextKey.PAGE_SYSTEMPICTUREMANAGER_SUCCESSFULL])
def _loadPicturesFromServer(self, picturesPath: str): serverUrl = "http://" + str(cfgValue[CfgKey.SERVER_IP]) + ":" + str( cfgValue[CfgKey.SERVER_PORT]) + str( cfgValue[CfgKey.SERVER_RANDOM_URLIDS]) pictureRequest = self._getRequest(serverUrl) if pictureRequest == None: return pictureUrlsAsString = base64.b64decode( pictureRequest.content).decode('utf-8') pictureUrls = list(filter(None, pictureUrlsAsString.split(";"))) if len(pictureUrls) > 0: FileFolderService.removeIfExist(picturesPath) pictureDownloadThread = PictureDownloadThread( pictureUrls, picturesPath, None) pictureDownloadThread.start() while not pictureDownloadThread.isFinished(): pass
def cleanCustomBackground(self): for index, value in enumerate(self.globalVariable.getDefaultBackground()): if value[GreenscreenBackgroundService.IS_CUSTOM]: self.globalVariable.getDefaultBackground().remove(value) FileFolderService.removeIfExist(GreenscreenBackgroundService.getCustomBackgroundPath())