Пример #1
0
    def _loadCredentials(cls):
        local_storage = LocalStorage(cls._CREDENTIALS_PATH)
        local_storage.setFileName(cls._CREDENTIALS_FILENAME)

        if not local_storage.existFile():
            raise NameError("missing file for credentials")

        file_content = local_storage.getFileContent()
        cls._CREDENTIALS = loads(file_content)

        return cls
Пример #2
0
    def _loadToken(cls):
        local_storage = LocalStorage(cls._TOKEN_PATH)
        local_storage.setFileName(cls._TOKEN_FILENAME)

        if not local_storage.existFile():
            return False

        token_file=cls._TOKEN_PATH+"/"+cls._TOKEN_FILENAME
        with open(token_file, 'rb') as token:
            cls._TOKEN =pickle.load(token)

        return cls
Пример #3
0
    def _savePhisicalFiles(cls):

        if len(cls._FILES_FOUND) <= 0:
            return None

        index = 0
        for item in cls._FILES_FOUND:

            try:
                file = LocalStorage(cls._FOLDER_FORFILES)
                file.setFileName(item['fileName'])
                content = base64.urlsafe_b64decode(item['data'].encode('utf-8'))
                file.saveFileContent(content=content, mode="wb")
                print(f"File Saved {item['fileName']}")

            except:
                print(f"Fail to save the file {item['fileName']}")

        return cls