def proceed_start(self, auto_paging=False): col = self.anki.collection() lastImport = SETTINGS.EVERNOTE.LAST_IMPORT.fetch() SETTINGS.EVERNOTE.LAST_IMPORT.save(datetime.now().strftime(ANKNOTES.DATE_FORMAT)) lastImportStr = get_friendly_interval_string(lastImport) if lastImportStr: lastImportStr = ' [LAST IMPORT: %s]' % lastImportStr log_str = " > Starting Evernote Import: Page %3s Query: %s" % ( '#' + str(self.currentPage), settings.generate_evernote_query()) log_banner(log_str.ljust(ANKNOTES.FORMATTING.TEXT_LENGTH-len(lastImportStr)) + lastImportStr, append_newline=False, chr='=', length=0, center=False, clear=False, timestamp=True) if auto_paging: return True notestore_status = self.evernote.initialize_note_store() if not notestore_status == EvernoteAPIStatus.Success: log(" > Note store does not exist. Aborting.") show_tooltip("Could not connect to Evernote servers (Status Code: %s)... Aborting." % notestore_status.name) return False self.evernote.getNoteCount = 0 return True
def get_evernote_metadata(self): """ :returns: Metadata Progress Instance :rtype : EvernoteMetadataProgress) """ query = settings.generate_evernote_query() evernote_filter = NoteFilter(words=query, ascending=True, order=NoteSortOrder.UPDATED) self.MetadataProgress = EvernoteMetadataProgress(self.currentPage) spec = NotesMetadataResultSpec(includeTitle=False, includeUpdated=False, includeUpdateSequenceNum=True, includeTagGuids=True, includeNotebookGuid=True) notestore_status = self.evernote.initialize_note_store() if not notestore_status.IsSuccess: self.MetadataProgress.Status = notestore_status return False # notestore_status api_action_str = u'trying to search for note metadata' log_api("findNotesMetadata", "[Offset: %3d]: Query: '%s'" % (self.MetadataProgress.Offset, query)) try: result = self.evernote.noteStore.findNotesMetadata(self.evernote.token, evernote_filter, self.MetadataProgress.Offset, EVERNOTE.IMPORT.METADATA_RESULTS_LIMIT, spec) """ :type: NotesMetadataList """ except EDAMSystemException as e: if not HandleEDAMRateLimitError(e, api_action_str) or EVERNOTE.API.DEBUG_RAISE_ERRORS: raise self.MetadataProgress.Status = EvernoteAPIStatus.RateLimitError return False except socket.error as v: if not HandleSocketError(v, api_action_str) or EVERNOTE.API.DEBUG_RAISE_ERRORS: raise self.MetadataProgress.Status = EvernoteAPIStatus.SocketError return False self.MetadataProgress.loadResults(result) self.evernote.metadata = self.MetadataProgress.NotesMetadata log(self.MetadataProgress.Summary, line_padding_header="- Metadata Results: ", line_padding=ANKNOTES.FORMATTING.LINE_PADDING_HEADER, timestamp=False) return True