コード例 #1
0
ファイル: dropbox.py プロジェクト: jfveronelli/sqink
    def add(self, note):
        """
        The note lastModified time is updated from Dropbox when the operations succeeds (unfortunately there's no way to
        set the modified time in Dropbox).
        """
        uuid= note.uuid
        result= self.__client.put_file(self.__notePath(uuid), marshalNote(note))
        if len(result["path"]) != len(self.__notePath(uuid)):
            try:
                self.__client.file_delete(result["path"])
            except ErrorResponse:
                pass
            raise RuntimeError("Note[uuid=%s] already exists" % uuid)
        note.lastModified= getLastModified(result)

        if note.photo:
            self.__client.put_file(self.__photoPath(uuid), note.photo, overwrite=True)
        elif uuid in self.__notesCache and self.__notesCache[uuid].hasPhoto:
            try:
                self.__client.file_delete(self.__photoPath(uuid))
            except ErrorResponse:
                pass
        renderHtml(note)

        #Clean removed note if exists
        if uuid in self.__notesCache and self.__notesCache[uuid].removed:
            try:
                self.__client.file_delete(self.__removedNotePath(uuid))
            except ErrorResponse:
                pass
コード例 #2
0
ファイル: gdrive.py プロジェクト: vijo/sqink
    def update(self, note):
        uuid= note.uuid
        ns= self.__noteStatusCache.get(uuid)
        if not ns or ns.removed:
            raise RuntimeError("Note[uuid=%s] does not exist" % uuid)
        if ns.hasPhoto:
            self.__remove(ns.photoId)

        content= MediaIoBaseUpload(BytesIO(marshalNote(note)), mimetype=self.NOTE_MIMETYPE, chunksize=-1, resumable=True)
        response= self._service().update(fileId=ns.noteId, newRevision=False, setModifiedDate=True,
                body={"modifiedDate": self.__modifiedDate(note)}, media_body=content, fields="parents(id)").execute()
        self.__updateFolderId(response)
        if note.photo:
            self.__uploadPhoto(note)
コード例 #3
0
ファイル: gdrive.py プロジェクト: resonancellc/sqink
    def update(self, note):
        uuid = note.uuid
        ns = self.__noteStatusCache.get(uuid)
        if not ns or ns.removed:
            raise RuntimeError("Note[uuid=%s] does not exist" % uuid)
        if ns.hasPhoto:
            _LOG.info("Deleting photo: %s", uuid)
            self.__remove(ns.photoId)

        _LOG.info("Updating note: %s", uuid)
        metadata = {"modifiedTime": self.__modifiedTime(note)}
        content = MediaIoBaseUpload(BytesIO(marshalNote(note)), mimetype=self.NOTE_MIMETYPE)
        self._service().update(fileId=ns.noteId, body=metadata, media_body=content, fields="id").execute()
        if note.photo:
            self.__uploadPhoto(note)
コード例 #4
0
    def update(self, note):
        uuid = note.uuid
        # Check if note exists
        if self.__notesCache and (uuid not in self.__notesCache or self.__notesCache[uuid].removed):
            raise RuntimeError("Note[uuid=%s] does not exist" % uuid)

        _LOG.info("Updating note: %s", uuid)
        self.__uploadFile(self.__notePath(uuid), note.lastModified, marshalNote(note))

        if note.photo:
            _LOG.info("Updating photo: %s", uuid)
            self.__uploadFile(self.__photoPath(uuid), note.lastModified, note.photo)
        elif uuid not in self.__notesCache or self.__notesCache[uuid].hasPhoto:
            _LOG.info("Deleting photo: %s", uuid)
            try:
                self.__client.files_delete(self.__photoPath(uuid))
            except ApiError:
                _LOG.warning("Photo %s not found", uuid)
コード例 #5
0
ファイル: gdrive.py プロジェクト: vijo/sqink
    def add(self, note):
        uuid= note.uuid
        if uuid in self.__noteStatusCache:
            ns= self.__noteStatusCache[uuid]
            if not ns.removed:
                raise RuntimeError("Note[uuid=%s] already exists" % uuid)
            else:
                self.__remove(ns.noteId)

        metadata= {
            "title": uuid + self.NOTE_EXTENSION,
            "mimeType": self.NOTE_MIMETYPE,
            "parents": [{"id": self.__folderId}],
            "modifiedDate": self.__modifiedDate(note)
        }
        content= MediaIoBaseUpload(BytesIO(marshalNote(note)), mimetype=self.NOTE_MIMETYPE, chunksize=-1, resumable=True)
        response= self._service().insert(body=metadata, media_body=content, fields="parents(id)").execute()
        self.__updateFolderId(response)
        if note.photo:
            self.__uploadPhoto(note)
コード例 #6
0
ファイル: dropbox.py プロジェクト: jfveronelli/sqink
    def update(self, note):
        """
        The note lastModified time is updated from Dropbox when the operations succeeds (unfortunately there's no way to
        set the modified time in Dropbox).
        """
        uuid= note.uuid
        #Check if note exists
        if self.__notesCache and (uuid not in self.__notesCache or self.__notesCache[uuid].removed):
            raise RuntimeError("Note[uuid=%s] does not exist" % uuid)

        result= self.__client.put_file(self.__notePath(uuid), marshalNote(note), overwrite=True)
        note.lastModified= getLastModified(result)

        if note.photo:
            self.__client.put_file(self.__photoPath(uuid), note.photo, overwrite=True)
        elif uuid not in self.__notesCache or self.__notesCache[uuid].hasPhoto:
            try:
                self.__client.file_delete(self.__photoPath(uuid))
            except ErrorResponse:
                pass
        renderHtml(note)
コード例 #7
0
ファイル: gdrive.py プロジェクト: resonancellc/sqink
    def add(self, note):
        uuid = note.uuid
        if uuid in self.__noteStatusCache:
            ns = self.__noteStatusCache[uuid]
            if not ns.removed:
                raise RuntimeError("Note[uuid=%s] already exists" % uuid)
            else:
                _LOG.info("Deleting REMOVED note: %s", uuid)
                self.__remove(ns.noteId)

        metadata = {
            "name": uuid + self.NOTE_EXTENSION,
            "modifiedTime": self.__modifiedTime(note),
            "mimeType": self.NOTE_MIMETYPE,
            "parents": [self.FOLDER]
        }
        content = MediaIoBaseUpload(BytesIO(marshalNote(note)), mimetype=self.NOTE_MIMETYPE)
        _LOG.info("Adding note: %s", uuid)
        self._service().create(body=metadata, media_body=content, fields="id").execute()
        if note.photo:
            self.__uploadPhoto(note)
コード例 #8
0
    def add(self, note):
        uuid = note.uuid
        _LOG.info("Adding note: %s", uuid)
        self.__uploadFile(self.__notePath(uuid), note.lastModified, marshalNote(note), overwrite=False)

        if note.photo:
            _LOG.info("Adding photo: %s", uuid)
            self.__uploadFile(self.__photoPath(uuid), note.lastModified, note.photo)
        elif uuid in self.__notesCache and self.__notesCache[uuid].hasPhoto:
            _LOG.info("Deleting photo: %s", uuid)
            try:
                self.__client.files_delete(self.__photoPath(uuid))
            except ApiError:
                _LOG.warning("Photo %s not found", uuid)

        # Clean removed note if exists
        if uuid in self.__notesCache and self.__notesCache[uuid].removed:
            _LOG.info("Deleting REMOVED note: %s", uuid)
            try:
                self.__client.files_delete(self.__removedNotePath(uuid))
            except ApiError:
                _LOG.warning("REMOVED note %s not found", uuid)