def list_items(service, type, refresh): items = [] notebooks = [] sections = [] if (service == "evernote"): if (type == "notebooks"): # Connecting to Evernote access_token = get_access_token() note_store = get_note_store(access_token) # Loading a list of notebooks notebooks = list_notebooks(note_store, access_token, refresh) # Collecting items for notebook in notebooks: items.append({ "name": notebook['name'].encode('utf-8'), "guid": notebook['guid'].encode('utf-8'), "parent": "--" }) elif (service == "onenote"): if type == "notebooks": notebooks = list_on_notebooks( get_access_token(safeglobals.service_onenote), refresh) for notebook in notebooks: items.append({ "name": notebook['text'], "guid": notebook['guid'], "parent": "--" }) elif type == "sections": sections = list_sections_all( get_access_token(safeglobals.service_onenote), refresh) for section in sections: items.append({ "name": section['text'], "guid": section['guid'], "parent": section['parent'] }) # Return items return items
def restore_from_backup(guid): # Getting the note from the backup guid = request.get_json().get('guid') note = get_from_backup(guid) if not note: abort(safeglobals.http_internal_server, {"message": ""}) # Getting Access Token access_token = get_access_token() # Getting the Note Store (connecting to Evernote) note_store = get_note_store(access_token) # Connecting to Evernote and updating the note update_note(note_store, access_token, note) # Sending the response return jsonify(status=safeglobals.http_ok, message=safeglobals.MSG_UPDATENOTE_OK)
def download_notes(note_store, access_token, query): # Connecting to Evernote account (getting note store) note_store = get_note_store(access_token) # Creating ResultSpec and NoteFilter noteFilter = NoteFilter(order=NoteSortOrder.UPDATED, notebookGuid=option.container, words=query) result_spec = NotesMetadataResultSpec(includeTitle=True, includeCreated=True, includeUpdated=True, includeNotebookGuid=True) # Getting the result print(" " + safeglobals.MSG_DOWNLOAD_NOTES + " ......"), response = note_store.findNotesMetadata(access_token, noteFilter, safeglobals.evernote_offset, safeglobals.evernote_maxnotes, result_spec) print safeglobals.MSG_LABEL_OK # Sending response return response
def notebooks(responseType): # Checking Access Token access_token = get_access_token() if access_token == "": abort(safeglobals.http_bad_request, {"message": safeglobals.ERROR_NO_TOKEN}) forceRefresh = False if request.args.get("refresh"): forceRefresh = str_to_bool(request.args.get("refresh")) # Connecting to Evernote note_store = get_note_store(access_token) # Getting a list of notebooks notebooks = list_notebooks(note_store, access_token, forceRefresh) # Returning response based on specified format return send_response( notebooks, responseType, { safeglobals.TYPE_SELECT: "select.notebooks.html", safeglobals.TYPE_HTML: "list.notebooks.html" })
hashes.append(file['hash']) # Creating a note if option.service == "evernote": # Creating content for resource in note.resources: content.append("<en-media type=\"%s\" hash=\"%s\"/><br/>" \ % (resource.mime,binascii.hexlify(resource.data.bodyHash))) note.content = "".join(content) # Encrypting note note.encrypt(password) # Connecting to Evernote note_store = get_note_store(access_token) # Uploading the note to server upload_note(note_store, access_token, note) elif option.service == "onenote": for resource in note.resources: if "image" in resource.mime: content.append( "<img src='name:%s' data-filename='%s' />" % (binascii.hexlify(resource.data.bodyHash, resource.attributes.fileName))) else: content.append( "<object data-attachment='%s' data='name:%s' type='%s'/>" %