<s> import hashlib <EOL> import binascii <EOL> import evernote . edam . userstore . constants as UserStoreConstants <EOL> import evernote . edam . type . ttypes as Types <EOL> from evernote . api . client import EvernoteClient <EOL> auth_token = "<STR_LIT>" <EOL> if auth_token == "<STR_LIT>" : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" "<STR_LIT>" <EOL> exit ( <NUM_LIT:1> ) <EOL> client = EvernoteClient ( token = auth_token , sandbox = True ) <EOL> user_store = client . get_user_store ( ) <EOL> version_ok = user_store . checkVersion ( <EOL> "<STR_LIT>" , <EOL> UserStoreConstants . EDAM_VERSION_MAJOR , <EOL> UserStoreConstants . EDAM_VERSION_MINOR <EOL> ) <EOL> print "<STR_LIT>" , str ( version_ok ) <EOL> print "<STR_LIT>" <EOL> if not version_ok : <EOL> exit ( <NUM_LIT:1> ) <EOL> note_store = client . get_note_store ( ) <EOL> notebooks = note_store . listNotebooks ( ) <EOL> print "<STR_LIT>" , len ( notebooks ) , "<STR_LIT>" <EOL> for notebook in notebooks : <EOL> print "<STR_LIT>" , notebook . name <EOL> print <EOL> print "<STR_LIT>" <EOL> print <EOL> note = Types . Note ( ) <EOL> note . title = "<STR_LIT>" <EOL> image = open ( '<STR_LIT>' , '<STR_LIT:rb>' ) . read ( ) <EOL> md5 = hashlib . md5 ( ) <EOL> md5 . update ( image ) <EOL> hash = md5 . digest ( ) <EOL> data = Types . Data ( ) <EOL> data . size = len ( image ) <EOL> data . bodyHash = hash <EOL> data . body = image <EOL> resource = Types . Resource ( ) <EOL> resource . mime = '<STR_LIT>' <EOL> resource . data = data <EOL> note . resources = [ resource ] <EOL> hash_hex = binascii . hexlify ( hash ) <EOL> note . content = '<STR_LIT>' <EOL> note . content += '<STR_LIT>' '<STR_LIT>' <EOL> note . content += '<STR_LIT>' <EOL> note . content += '<STR_LIT>' + hash_hex + '<STR_LIT>' <EOL> note . content += '<STR_LIT>' <EOL> created_note = note_store . createNote ( note ) <EOL> print "<STR_LIT>" , created_note . guid </s>
