示例#1
0
文件: Upload.py 项目: Fil0x/Cloudy
    def _googledrive_load(self):
        uploadManager = LocalUploadManager()
        uploadsFromFile = uploadManager.get_uploads("GoogleDrive")

        for k, v in uploadsFromFile.items():
            # Check if the file still exists
            try:
                with open(v["path"], "r"):
                    pass
            except IOError:
                self.pending_uploads["GoogleDrive"][k] = {
                    "error": "File not found",
                    "status": "Error-2",
                    "path": v["path"],
                }
                continue

            if "offset" not in v:
                self.pending_uploads["GoogleDrive"][k] = {
                    "error": "File not found",
                    "status": "Error-2",
                    "path": v["path"],
                }
                continue

            offset = int(v["offset"])
            upload_uri = None if v["upload_uri"] == "None" else v["upload_uri"]
            gdUploader = GoogleDriveUploader(v["path"], v["destination"], v["parent_id"], offset, upload_uri)

            self.pending_uploads["GoogleDrive"][k] = {
                "uploader": gdUploader,
                "status": v["status"],
                "conflict": v["conflict"],
            }
示例#2
0
文件: Upload.py 项目: Fil0x/Cloudy
    def _googledrive_save(self):
        def create_dict(item):
            state = self._normalize_state(item['status'])
            return {
                'upload_uri': item['uploader'].upload_uri or 'None',
                'offset': item['uploader'].offset,
                'path': item['uploader'].path,
                'destination': item['uploader'].remote,
                'parent_id': item['uploader'].parent_id,
                'status': state,
                'conflict': item['conflict']
            }

        uploadManager = LocalUploadManager()
        uploadManager.delete_upload('GoogleDrive')

        for k, v in self.pending_uploads['GoogleDrive'].iteritems():
            if v['status'] == 'Removing':
                continue  #Dont save the uploads with Removing status.
            elif v['status'] == 'Error-2':
                ''' If the status is error-2 this can mean two things:
                    1)the upload raised this error in this app session,
                    2)the erroneous upload wasn't removed by the user
                     and it has lived at least one app session.
                '''
                if 'error' not in v:  #1
                    uploadManager.add_upload('GoogleDrive', k,
                                             **{'path': v['uploader'].path})
                else:  #2
                    uploadManager.add_upload('GoogleDrive', k,
                                             **{'path': v['path']})
            else:
                d = create_dict(v)
                uploadManager.add_upload('GoogleDrive', k, **d)
示例#3
0
文件: Upload.py 项目: Fil0x/Cloudy
    def _dropbox_load(self):
        uploadManager = LocalUploadManager()
        uploadsFromFile = uploadManager.get_uploads("Dropbox")

        for k, v in uploadsFromFile.iteritems():
            try:
                with open(v["path"], "r"):
                    pass
            except IOError:
                self.pending_uploads["Dropbox"][k] = {"error": "File not found", "status": "Error-2", "path": v["path"]}
                continue

            if "offset" not in v:
                self.pending_uploads["Dropbox"][k] = {"error": "File not found", "status": "Error-2", "path": v["path"]}
                continue

            offset = int(v["offset"])
            upload_id = None if v["upload_id"] == "None" else v["upload_id"]
            dbUploader = DropboxUploader(v["path"], v["destination"], offset, upload_id)

            self.pending_uploads["Dropbox"][k] = {
                "uploader": dbUploader,
                "status": v["status"],
                "conflict": v["conflict"],
            }
示例#4
0
文件: Upload.py 项目: Fil0x/Cloudy
    def _dropbox_load(self):
        uploadManager = LocalUploadManager()
        uploadsFromFile = uploadManager.get_uploads('Dropbox')

        for k, v in uploadsFromFile.iteritems():
            try:
                with open(v['path'], 'r'):
                    pass
            except IOError:
                self.pending_uploads['Dropbox'][k] = {
                    'error': 'File not found',
                    'status': 'Error-2',
                    'path': v['path']
                }
                continue

            if 'offset' not in v:
                self.pending_uploads['Dropbox'][k] = {
                    'error': 'File not found',
                    'status': 'Error-2',
                    'path': v['path']
                }
                continue

            offset = int(v['offset'])
            upload_id = None if v['upload_id'] == 'None' else v['upload_id']
            dbUploader = DropboxUploader(v['path'], v['destination'], offset,
                                         upload_id)

            self.pending_uploads['Dropbox'][k] = {
                'uploader': dbUploader,
                'status': v['status'],
                'conflict': v['conflict']
            }
示例#5
0
文件: Upload.py 项目: Fil0x/Cloudy
    def _pithos_load(self):
        uploadManager = LocalUploadManager()
        uploadsFromFile = uploadManager.get_uploads('Pithos')

        for k, v in uploadsFromFile.iteritems():
            try:
                with open(v['path'], 'r'):
                    pass
            except IOError:
                self.pending_uploads['Pithos'][k] = {
                    'error': 'File not found',
                    'status': 'Error-2',
                    'path': v['path']
                }
                continue

            if 'offset' not in v:
                self.pending_uploads['Pithos'][k] = {
                    'error': 'File not found',
                    'status': 'Error-2',
                    'path': v['path']
                }
                continue

            offset = int(v['offset'])
            pithosUploader = PithosUploader(v['path'], v['destination'],
                                            offset)

            self.pending_uploads['Pithos'][k] = {
                'uploader': pithosUploader,
                'status': v['status'],
                'conflict': v['conflict']
            }
示例#6
0
文件: Upload.py 项目: Fil0x/Cloudy
    def _googledrive_save(self):
        def create_dict(item):
            state = self._normalize_state(item["status"])
            return {
                "upload_uri": item["uploader"].upload_uri or "None",
                "offset": item["uploader"].offset,
                "path": item["uploader"].path,
                "destination": item["uploader"].remote,
                "parent_id": item["uploader"].parent_id,
                "status": state,
                "conflict": item["conflict"],
            }

        uploadManager = LocalUploadManager()
        uploadManager.delete_upload("GoogleDrive")

        for k, v in self.pending_uploads["GoogleDrive"].iteritems():
            if v["status"] == "Removing":
                continue  # Dont save the uploads with Removing status.
            elif v["status"] == "Error-2":
                """ If the status is error-2 this can mean two things:
                    1)the upload raised this error in this app session,
                    2)the erroneous upload wasn't removed by the user
                     and it has lived at least one app session.
                """
                if "error" not in v:  # 1
                    uploadManager.add_upload("GoogleDrive", k, **{"path": v["uploader"].path})
                else:  # 2
                    uploadManager.add_upload("GoogleDrive", k, **{"path": v["path"]})
            else:
                d = create_dict(v)
                uploadManager.add_upload("GoogleDrive", k, **d)
示例#7
0
文件: Upload.py 项目: Fil0x/Cloudy
    def _pithos_load(self):
        uploadManager = LocalUploadManager()
        uploadsFromFile = uploadManager.get_uploads("Pithos")

        for k, v in uploadsFromFile.iteritems():
            try:
                with open(v["path"], "r"):
                    pass
            except IOError:
                self.pending_uploads["Pithos"][k] = {"error": "File not found", "status": "Error-2", "path": v["path"]}
                continue

            if "offset" not in v:
                self.pending_uploads["Pithos"][k] = {"error": "File not found", "status": "Error-2", "path": v["path"]}
                continue

            offset = int(v["offset"])
            pithosUploader = PithosUploader(v["path"], v["destination"], offset)

            self.pending_uploads["Pithos"][k] = {
                "uploader": pithosUploader,
                "status": v["status"],
                "conflict": v["conflict"],
            }
示例#8
0
文件: Upload.py 项目: Fil0x/Cloudy
    def _googledrive_load(self):
        uploadManager = LocalUploadManager()
        uploadsFromFile = uploadManager.get_uploads('GoogleDrive')

        for k, v in uploadsFromFile.items():
            #Check if the file still exists
            try:
                with open(v['path'], 'r'):
                    pass
            except IOError:
                self.pending_uploads['GoogleDrive'][k] = {
                    'error': 'File not found',
                    'status': 'Error-2',
                    'path': v['path']
                }
                continue

            if 'offset' not in v:
                self.pending_uploads['GoogleDrive'][k] = {
                    'error': 'File not found',
                    'status': 'Error-2',
                    'path': v['path']
                }
                continue

            offset = int(v['offset'])
            upload_uri = None if v['upload_uri'] == 'None' else v['upload_uri']
            gdUploader = GoogleDriveUploader(v['path'], v['destination'],
                                             v['parent_id'], offset,
                                             upload_uri)

            self.pending_uploads['GoogleDrive'][k] = {
                'uploader': gdUploader,
                'status': v['status'],
                'conflict': v['conflict']
            }
示例#9
0
文件: Upload.py 项目: Fil0x/Cloudy
    def delete_history(self, service, id=None):
        upload_manager = LocalUploadManager()

        upload_manager.delete_history(service, id)
示例#10
0
文件: Upload.py 项目: Fil0x/Cloudy
    def get_history(self, service=None, id=None):
        upload_manager = LocalUploadManager()

        return upload_manager.get_history(service, id)
示例#11
0
文件: Upload.py 项目: Fil0x/Cloudy
    def add_history(self, service, id, **kwargs):
        """ name=remote_filename, date=date, path=remote path, link=share_link """
        upload_manager = LocalUploadManager()

        upload_manager.add_history(service, id, **kwargs)
示例#12
0
文件: Upload.py 项目: Fil0x/Cloudy
    def delete_history(self, service, id=None):
        upload_manager = LocalUploadManager()

        upload_manager.delete_history(service, id)
示例#13
0
文件: Upload.py 项目: Fil0x/Cloudy
    def get_history(self, service=None, id=None):
        upload_manager = LocalUploadManager()

        return upload_manager.get_history(service, id)
示例#14
0
文件: Upload.py 项目: Fil0x/Cloudy
    def add_history(self, service, id, **kwargs):
        ''' name=remote_filename, date=date, path=remote path, link=share_link '''
        upload_manager = LocalUploadManager()

        upload_manager.add_history(service, id, **kwargs)