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
 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)
Exemple #4
0
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 _savePicture(targetFolder, fileName):
     sourceFile = ShottedPictureService.getTempPicturePath()
     targetPath = os.path.join(
         targetFolder, fileName + CfgService.get(CfgKey.PICTURE_FORMAT))
     unicTargetPath = ShottedPictureService._getUnicFileName(targetPath)
     FileFolderService.moveFile(sourceFile, unicTargetPath)
     return FileFolderService.getAbsoltPath(unicTargetPath)
 def getContentFileType(self, request, url):
     contentDisposition = 'content-disposition'
     if contentDisposition in request.headers:
         d = request.headers[contentDisposition]
         fileName = re.findall("filename=(.+)", d)[0]
         return FileFolderService.getFileType(fileName)
     else:
         return FileFolderService.getFileType(url)
 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)
Exemple #8
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()
Exemple #9
0
    def __init__(self):
        self.dbConnection = None

        dbPathWithName = FileFolderService.getAbsoltPath(self._getDBPath())
        FileFolderService.creatFolderByFileIfNotExist(dbPathWithName)

        self.TABLE_NAME = "PRINTING_LIMITATION"
        self.TABLE_COLUMN_PICTURE_NAME = "PICTURE_NAME"
        self.TABLE_COLUMN_ORDER_NUMBER = "ORDER_NUMBER"

        self.dbConnection = sqlite3.connect(dbPathWithName)
        self._createTableIfNotExist()
Exemple #10
0
 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])
Exemple #11
0
 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])
Exemple #12
0
def displayBackground_image(uuid,number):
    print("PictureHash: "+number)
    if uuid is None:
        abort(404)
    authorizade = ServerDbSevice.getBackgroundUploadAuthorization(uuid)
    if authorizade is None:
        abort(404)
    filePath = GreenscreenBackgroundService.getCustomFilePathWithName(authorizade["targetPath"],uuid)
    imageAsByte = FileFolderService.readImage(filePath)
    return send_file(io.BytesIO(imageAsByte),
                     as_attachment=True,
                     attachment_filename=FileFolderService.getFileName(filePath),
                     mimetype='image/'+FileFolderService.getFileType(filePath).replace("\.",""))
Exemple #13
0
    def __init__(self):
        self.dbConnection = None

        dbPathWithName = FileFolderService.getAbsoltPath(self._getDBPath())
        FileFolderService.creatFolderByFileIfNotExist(dbPathWithName)

        self.TABLE_NAME = "PRINT"
        self.TABLE_COLUMN_ID = "ID"
        self.TABLE_COLUMN_PICTURE_NAME = "PICTURE_NAME"
        self.TABLE_COLUMN_JOBID = "JOB_ID"

        self.dbConnection = sqlite3.connect(dbPathWithName)
        self._createTableIfNotExist()
Exemple #14
0
    def __init__(self):
        self.dbConnection = None

        dbPathWithName = FileFolderService.getAbsoltPath(self._getDBPath())

        FileFolderService.creatFolderByFileIfNotExist(dbPathWithName)

        self.TABLE_NAME = "BACKGROUND"
        self.TABLE_COLUMN_ID = "UUID"
        self.TABLE_COLUMN_CLEAN = "CLEAN_BEFORE"
        self.TABLE_COLUMN_TARGETPATH = "TARGET_PATH"

        self.dbConnection = sqlite3.connect(dbPathWithName)
        self._createTableIfNotExist()
Exemple #15
0
def downloadPicture(urlId):
    picturePathAndName = ServerDbSevice.getPicturePathAndName(urlId)
    if not picturePathAndName:
        abort(404)
    else :
        imageAsByte = FileFolderService.readImage(picturePathAndName[1])
        return send_file(io.BytesIO(imageAsByte),
                         as_attachment=True,
                         attachment_filename=CfgService.get(CfgKey.PROJECTNAME)+"_"+picturePathAndName[0]+'.png',
                         mimetype='image/png')
Exemple #16
0
 def _getPicturesByPath(self, picturesPath: str,
                        pictureConfig: PicturesConfig, framePath: str):
     pictures = []
     for picturePath in FileFolderService.getFolderContentPictures(
             picturesPath):
         picture = Picture(picturePath, pictureConfig)
         if framePath != None:
             picture.setFramePath(framePath)
         pictures.append(picture)
     return pictures
Exemple #17
0
    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 _savePreview(self,image,sourcePath:str,isCustom:bool):
     fileName = FileFolderService.getFileName(sourcePath)
     if isCustom:
         fileName = CfgService.get(CfgKey.GREENSCREEN_CUSTOM_BACKGROUND_PREVIEW_FILENAME)+fileName
         filePath = os.path.join(GreenscreenBackgroundService.getCustomBackgroundPath(), fileName)
     else:
         filePath = os.path.join(self._getTempPath(), fileName)
     windowSize = self.globalVariable.getWindowSize()
     preview = image.resize((windowSize.width(),windowSize.height()))
     preview.save(filePath)
     return filePath
    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 #20
0
    def setHints(self):
        self.textArea.clear()
        self.textArea.append(textValue[TextKey.PAGE_HINTS_ESCAPE_HINT])
        self.textArea.append("")
        self.textArea.append(textValue[TextKey.PAGE_HINTS_RECONFIG_HINT])
        self.textArea.append("")

        if not CameraService.existCameras() and not CameraService.existPiCamera():
            self.textArea.append(textValue[TextKey.PAGE_HINTS_NO_CAMERA_WARN])
            self.textArea.append("")
        elif not CameraService.existSelectedCamera() and not CameraService.existPiCamera():
            self.textArea.append(textValue[TextKey.PAGE_HINTS_NO_SELECTED_CAMERA_WARN])
            self.textArea.append("")
            #Erfolgsfaelle###########################################################################
        elif CameraService.existPiCamera():
            cameraInfoText = textValue[TextKey.PAGE_HINTS_SELECTED_PICAMERA_HINT]
            self.textArea.append(cameraInfoText)
            self.textArea.append("")
        else:
            cameraInfoText = textValue[TextKey.PAGE_HINTS_SELECTED_CAMERA_HINT] % (str(CameraService.getCameraIndex()),CameraService.getCameraName(), CameraService.getCameraDescription())
            self.textArea.append(cameraInfoText)
            self.textArea.append("")

        if not FileFolderService.hasFolderContent(CfgService.get(CfgKey.PAGE_TITLEPICTURE_BUTTON_IMAGE_FOLDER)):
            warn = textValue[TextKey.PAGE_HINTS_NO_PICTURES_FOUND_WARN] % (CfgService.get(CfgKey.PAGE_TITLEPICTURE_BUTTON_IMAGE_FOLDER))
            self.textArea.append(warn)
            self.textArea.append("")

        if not FileFolderService.hasFolderContent(CfgService.get(CfgKey.PAGE_CAPTUREPHOTO_LAST_IMAGE_FOLDER)):
            warn = textValue[TextKey.PAGE_HINTS_NO_PICTURES_FOUND_WARN] % (CfgService.get(CfgKey.PAGE_CAPTUREPHOTO_LAST_IMAGE_FOLDER))
            self.textArea.append(warn)
            self.textArea.append("")

        if not FileFolderService.hasFolderContent(CfgService.get(CfgKey.PAGE_CAPTUREPHOTO_LOADING_GIF_FOLDER)):
            warn = textValue[TextKey.PAGE_HINTS_NO_PICTURES_FOUND_WARN] % (CfgService.get(CfgKey.PAGE_CAPTUREPHOTO_LOADING_GIF_FOLDER))
            self.textArea.append(warn)
            self.textArea.append("")

        #Printer hint
        self.textArea.append(textValue[TextKey.PAGE_HINTS_PRINTER_STATUS_LABEL]+self.printerService.getPrinterStatus())
    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)
Exemple #22
0
 def updateFunnyPictures(self):
     self.disableAllButtons()
     urls = FileFolderService.readFile(
         CfgService.get(
             CfgKey.PAGE_SYSTEMPICTUREMANAGER_FUNNY_PICTURE_SOURCE))
     if (len(urls) > 0):
         self.thread = PictureDownloadThread(
             urls,
             CfgService.get(CfgKey.PAGE_CAPTUREPHOTO_LAST_IMAGE_FOLDER),
             CfgService.get(
                 CfgKey.
                 PAGE_SYSTEMPICTUREMANAGER_FUNNY_PICTURE_SOURCE_SUCCESS_DOWNLOAD
             ))
         self.thread._signal.connect(self.signal_accept)
         self.thread.start()
     else:
         self.enableAllButtons()
         self.funnyUpdateButton.setText(
             textValue[TextKey.PAGE_SYSTEMPICTUREMANAGER_SUCCESSFULL])
    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 cleanCustomBackground(self):
        for index, value in enumerate(self.globalVariable.getDefaultBackground()):
            if value[GreenscreenBackgroundService.IS_CUSTOM]:
                self.globalVariable.getDefaultBackground().remove(value)

        FileFolderService.removeIfExist(GreenscreenBackgroundService.getCustomBackgroundPath())
Exemple #25
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)
Exemple #26
0
 def _saveProperty(self, existKeyValuePairs:dict, key:CfgKey, value):
     existKeyValuePairs[key._name_] = str(value)
     propertiesLines = []
     for key in existKeyValuePairs:
         propertiesLines.append(str(key)+self.KEY_VALUE_SEPPARATOR+str(existKeyValuePairs[key]))
     FileFolderService.writeLinesInFile(False,self.propertiesPath,propertiesLines)
Exemple #27
0
    def update(self):
        subFolderDirs = FileFolderService.getFolderContentFolders(
            cfgValue[CfgKey.DIASHOW_CLIENT_PICTURE_MAIN_FOLDER])

        for subFolderDir in subFolderDirs:
            self._updatePictureSource(subFolderDir)
Exemple #28
0
 def _checkImageExist(self, id: str, path: str):
     if (FileFolderService.existFile(path)):
         return True
     else:
         self._deletById(id)
         return False
 def _getBackgroundPathCreateFolderIfNotExtist(self):
     folder = GreenscreenBackgroundService.getDefaultBackgroundPath()
     FileFolderService.createFolderIfNotExist(folder)
     return folder
Exemple #30
0
 def hasPageCapturePhotoLoadungGifs(self):
     return FileFolderService.hasFolderContent(CfgService.get(CfgKey.PAGE_CAPTUREPHOTO_LOADING_GIF_FOLDER))