예제 #1
0
파일: gdrive.py 프로젝트: vijo/sqink
 def get(self, uuid):
     ns= self.__noteStatusCache.get(uuid)
     if not ns or ns.removed:
         raise RuntimeError("Note[uuid=%s] does not exist" % uuid)
     content= self._service().get_media(fileId=ns.noteId).execute()
     note= unmarshalNote(content, ns.lastModified)
     if ns.hasPhoto:
         note.photo= self._service().get_media(fileId=ns.photoId).execute()
     return renderHtml(note)
예제 #2
0
 def get(self, uuid):
     ns = self.__noteStatusCache.get(uuid)
     if not ns or ns.removed:
         raise RuntimeError("Note[uuid=%s] does not exist" % uuid)
     _LOG.info("Getting note: %s", uuid)
     content = self._service().get_media(fileId=ns.noteId).execute()
     note = unmarshalNote(content, ns.lastModified)
     if ns.hasPhoto:
         _LOG.info("Getting photo: %s", uuid)
         note.photo = self._service().get_media(fileId=ns.photoId).execute()
     return renderHtml(note)
예제 #3
0
 def get(self, uuid):
     response, metadata= self.__client.get_file_and_metadata(self.__notePath(uuid))
     with response:
         note= unmarshalNote(response.read(), getLastModified(metadata))
     if uuid not in self.__notesCache or self.__notesCache[uuid].hasPhoto:
         try:
             with self.__client.get_file(self.__photoPath(uuid)) as response:
                 note.photo= response.read()
         except ErrorResponse as e:
             if e.status == 404: #Photo does not exist
                 pass
             else:
                 raise e
     return renderHtml(note)
예제 #4
0
 def get(self, uuid):
     _LOG.info("Getting note: %s", uuid)
     metadata, response = self.__client.files_download(self.__notePath(uuid))
     with response:
         note = unmarshalNote(response.content, metadata.client_modified)
     if uuid not in self.__notesCache or self.__notesCache[uuid].hasPhoto:
         _LOG.info("Getting photo: %s", uuid)
         try:
             with self.__client.files_download(self.__photoPath(uuid))[1] as response:
                 note.photo = response.content
         except ApiError as e:
             if e.error.is_path() and e.error.get_path().is_not_found():
                 _LOG.warning("Photo %s does not exist", uuid)
             else:
                 raise e
     return renderHtml(note)