本文整理汇总了Python中evernote.api.client.EvernoteClient方法的典型用法代码示例。如果您正苦于以下问题:Python client.EvernoteClient方法的具体用法?Python client.EvernoteClient怎么用?Python client.EvernoteClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类evernote.api.client
的用法示例。
在下文中一共展示了client.EvernoteClient方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_request_token
# 需要导入模块: from evernote.api import client [as 别名]
# 或者: from evernote.api.client import EvernoteClient [as 别名]
def get_request_token(user, callback):
'''
Get request token
'''
from settings import secrets
client = EvernoteClient(
consumer_key=secrets.EVERNOTE_CONSUMER_KEY,
consumer_secret=secrets.EVERNOTE_CONSUMER_SECRET,
sandbox=SANDBOX
)
request_token = client.get_request_token(callback)
logging.debug(request_token)
# Save secret
memcache.set(SECRET_MCK % user.key.id(), request_token['oauth_token_secret'])
authorize_url = client.get_authorize_url(request_token)
return authorize_url
示例2: get_note
# 需要导入模块: from evernote.api import client [as 别名]
# 或者: from evernote.api.client import EvernoteClient [as 别名]
def get_note(user, note_id):
STRIP_WORDS = ["Pocket:"]
title = url = content = None
access_token = user_access_token(user)
if access_token:
client = EvernoteClient(token=access_token, sandbox=SANDBOX)
noteStore = client.get_note_store()
note = noteStore.getNote(access_token, note_id, True, False, False, False)
if note:
logging.debug(note)
content = extract_clipping_content(note.content)
title = note.title
uid = note.guid
for sw in STRIP_WORDS:
if sw in title:
title = title.replace(sw, '')
title = title.strip()
attrs = note.attributes
if attrs:
url = attrs.sourceURL
else:
logging.debug("Note not found")
else:
logging.warning("Access token not available")
return (uid, title, content, url)
示例3: _get_client
# 需要导入模块: from evernote.api import client [as 别名]
# 或者: from evernote.api.client import EvernoteClient [as 别名]
def _get_client():
global _client
if _client is None:
log_progress('login to evernote')
_client = EvernoteClient(token=_auth_token, sandbox=False)
return _client
示例4: __init__
# 需要导入模块: from evernote.api import client [as 别名]
# 或者: from evernote.api.client import EvernoteClient [as 别名]
def __init__(self, *args):
super(EvernoteModule, self).__init__(*args)
self.auth_token = self.get_configuration('evernote_auth_token')
if self.auth_token:
self.client = EvernoteClient(token=self.auth_token, sandbox=False)
self.user_store = self.client.get_user_store()
self.note_store = self.client.get_note_store()
else:
return False
示例5: _connect_to_evernote
# 需要导入模块: from evernote.api import client [as 别名]
# 或者: from evernote.api.client import EvernoteClient [as 别名]
def _connect_to_evernote(self, dictUserInfo):
"""
Establish a connection to evernote and authenticate.
:param dictUserInfo: Dict of user info like user/passwrod. For now, just the dev token
:returns success: Return wheter connection succeeded
:rtype bool:
"""
print("Authenticating to Evernote")
dev_token = dictUserInfo['dev_token']
logging.debug("Authenticating using token %s" % dev_token)
user = None
try:
self.client = EvernoteClient(token=dev_token, sandbox=False)
self.user_store = self.client.get_user_store()
user = self.user_store.getUser()
except EDAMUserException as e:
err = e.errorCode
print("Error attempting to authenticate to Evernote: %s - %s" % (EDAMErrorCode._VALUES_TO_NAMES[err], e.parameter))
except EDAMSystemException as e:
err = e.errorCode
print("Error attempting to authenticate to Evernote: %s - %s" % (EDAMErrorCode._VALUES_TO_NAMES[err], e.message))
sys.exit(-1)
if user:
print("Authenticated to evernote as user %s" % user.username)
return True
示例6: __init__
# 需要导入模块: from evernote.api import client [as 别名]
# 或者: from evernote.api.client import EvernoteClient [as 别名]
def __init__(self, token, isSpecialToken = False, sandbox = False, isInternational = False, notebooks = None):
self.token = token
if sandbox:
self.client = EvernoteClient(token=self.token)
elif isInternational:
self.client = EvernoteClient(token=self.token, service_host='www.evernote.com')
else:
self.client = EvernoteClient(token=self.token, service_host='app.yinxiang.com')
self.isSpecialToken = isSpecialToken
self.userStore = self.client.get_user_store()
self.noteStore = self.client.get_note_store()
self.storage = Storage(notebooks)
示例7: __init__
# 需要导入模块: from evernote.api import client [as 别名]
# 或者: from evernote.api.client import EvernoteClient [as 别名]
def __init__(self):
if DEV_TOKEN:
self.token = DEV_TOKEN
else:
self.token = Oauth(SANDBOX).oauth()
sys.stdout.write('Logging\r')
if SANDBOX:
self.client = EvernoteClient(token=self.token)
else:
self.client = EvernoteClient(token=self.token, service_host=SERVICE_HOST)
self.userStore = self.client.get_user_store()
self.noteStore = self.client.get_note_store()
if LOCAL_STORAGE: self.__set_storage()
print 'Login Succeed as ' + self.userStore.getUser().username
示例8: __init__
# 需要导入模块: from evernote.api import client [as 别名]
# 或者: from evernote.api.client import EvernoteClient [as 别名]
def __init__(self, token, isSpecialToken = False, sandbox = False, isInternational = False):
self.token = token
if sandbox:
self.client = EvernoteClient(token=self.token)
elif isInternational:
self.client = EvernoteClient(token=self.token, service_host='app.evernote.com')
else:
self.client = EvernoteClient(token=self.token, service_host='app.yinxiang.com')
self.isSpecialToken = isSpecialToken
self.userStore = self.client.get_user_store()
self.noteStore = self.client.get_note_store()
self.storage = Storage()
示例9: handle
# 需要导入模块: from evernote.api import client [as 别名]
# 或者: from evernote.api.client import EvernoteClient [as 别名]
def handle(text, mic, profile):
auth_token = profile["EVERNOTE_TOKEN"]
client = EvernoteClient(token=auth_token, sandbox=False)
user_store = client.get_user_store()
note_store = client.get_note_store()
if bool(re.search(r'\Note\b', text, re.IGNORECASE)):
writeNote(text, mic, note_store)
示例10: get_access_token
# 需要导入模块: from evernote.api import client [as 别名]
# 或者: from evernote.api.client import EvernoteClient [as 别名]
def get_access_token(user, oauth_token, oauth_verifier):
'''
Get request token
'''
from settings import secrets
client = EvernoteClient(
consumer_key=secrets.EVERNOTE_CONSUMER_KEY,
consumer_secret=secrets.EVERNOTE_CONSUMER_SECRET,
sandbox=SANDBOX
)
access_token = en_user_id = None
access_token_dict = {}
oauth_token_secret = memcache.get(SECRET_MCK % user.key.id())
if oauth_token_secret:
try:
access_token_dict = client.get_access_token_dict(
oauth_token,
oauth_token_secret,
oauth_verifier
)
except KeyError:
logging.warning("KeyError getting Evernote access token")
en_user_id = access_token_dict.get('edam_userId')
access_token = access_token_dict.get('oauth_token')
else:
logging.warning("oauth_token_secret unavailable")
return (access_token, en_user_id)
示例11: login
# 需要导入模块: from evernote.api import client [as 别名]
# 或者: from evernote.api.client import EvernoteClient [as 别名]
def login(self):
"""
login Evernote
"""
if self._test:
return True
log.debug('Start to login')
yx = False
if self.account_type == 'yinxiang':
yx = True
log.debug('Account type:' + 'yinxiang')
else:
log.debug('Account type:' + 'evernote')
try:
self.client = EvernoteClient(token=self.auth_token, sandbox=False, yinxiang=yx)
self.user_store = self.client.get_user_store()
version_ok = self.user_store.checkVersion("Evernote EDAMTest (Python)",
UserStoreConstants.EDAM_VERSION_MAJOR,
UserStoreConstants.EDAM_VERSION_MINOR)
if not version_ok:
log.error('Evernote SDK version not up to data')
return False
self.note_store = self.client.get_note_store()
log.info('Login succeed')
return True
except:
log.debug(traceback.format_exc())
log.error('Login failed')