本文整理汇总了Python中auth.Auth.authenticate方法的典型用法代码示例。如果您正苦于以下问题:Python Auth.authenticate方法的具体用法?Python Auth.authenticate怎么用?Python Auth.authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth.Auth
的用法示例。
在下文中一共展示了Auth.authenticate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upload_photos
# 需要导入模块: from auth import Auth [as 别名]
# 或者: from auth.Auth import authenticate [as 别名]
def upload_photos(set, photos, key, secret, checkpoint):
try:
auth = Auth(key, secret)
auth.authenticate()
except urllib2.HTTPError as e:
print e.read()
raise
set_controller = Photosets(auth)
# Work queue to print upload status
ui_wq = WorkQueue(print_status, num_workers = 1)
upload_and_add(photos[0], set, auth, set_controller, ui_wq, checkpoint)
wq = WorkQueue(upload_and_add,
num_workers = 16,
max_queue_size = 50,
set = set,
auth = auth,
set_controller = set_controller,
ui_wq = ui_wq,
checkpoint = checkpoint)
for photo in photos[1:]:
wq.add(photo)
wq.done()
ui_wq.done()
示例2: run_tests
# 需要导入模块: from auth import Auth [as 别名]
# 或者: from auth.Auth import authenticate [as 别名]
def run_tests(key, secret):
try:
x = Auth(key, secret)
x.authenticate()
except urllib2.HTTPError as e:
print e.read()
raise
filename = "/Users/riyer/Desktop/Screen Shot 2013-06-28 at 7.36.02 PM.png"
f = open(filename, "rb")
pic = f.read()
u = Uploader("test_pic", pic, x)
u.addTitle("test pic")
u.setPublic()
req = u.getRequest()
try:
handle = urllib2.urlopen(req)
res = handle.read()
except urllib2.HTTPError as e:
print e.read()
raise
photo_id = u.getPhotoIdFromResponse(res)
p = Photosets(x)
r = p.createGetListRequest()
res = execute(r, "createGetListRequest")
names = p.getPhotosetList(res)
r = p.createNewSetRequest("test set", "test desc", '9404583236')
res = execute(r, "createNewSetRequest")
set_id = p.getPhotosetIdFromResult(res)
r = p.createAddPhotoRequest(photo_id, set_id)
execute(r, "createAddPhotoRequest")
r = p.createPhotosetDeleteRequest(set_id)
execute(r, "createPhotosetDeleteRequest")
photos = Photos(x)
r = photos.createDeletePhotoRequest(photo_id)
execute(r, "createDeletePhotoRequest")
示例3: exit_with_error
# 需要导入模块: from auth import Auth [as 别名]
# 或者: from auth.Auth import authenticate [as 别名]
exit_with_error("Unable to find group '" + args['as_group'] +
"' in " + config_file)
username = common.get_user_value(args, config_data, 'os_username')
if username is None:
exit_with_error(None)
api_key = common.get_user_value(args, config_data, 'os_password')
if api_key is None:
exit_with_error(None)
region = common.get_user_value(args, config_data, 'os_region_name')
if region is None:
exit_with_error(None)
session = Auth(username, api_key, region)
if session.authenticate() is True:
rv = autoscale(as_group, config_data, args)
if rv is None:
log_file = None
if hasattr(logger.root.handlers[0], 'baseFilename'):
log_file = logger.root.handlers[0].baseFilename
if log_file is None:
logger.info('completed successfull')
else:
logger.info('completed successfully: %s' % log_file)
else:
exit_with_error(None)
else:
exit_with_error('Authentication failed')
示例4: Auth
# 需要导入模块: from auth import Auth [as 别名]
# 或者: from auth.Auth import authenticate [as 别名]
import hashlib
import binascii
import evernote.edam.userstore.constants as UserStoreConstants
import evernote.edam.type.ttypes as Types
from auth import Auth
from tag import Tag
from notebook import NoteBook
from note import Note
auth = Auth()
tags = Tag()
notebooks = NoteBook()
notes = Note()
#Authenticate the user using the oauth or developer toke
client = auth.authenticate()
user_store = client.get_user_store()
#Check whether the version is up to date with the latest version provided by evernote
version_ok = user_store.checkVersion(
"Evernote",
UserStoreConstants.EDAM_VERSION_MAJOR,
UserStoreConstants.EDAM_VERSION_MINOR
)
print("Is my Evernote API version up to date? ", str(version_ok))
print("")
if not version_ok:
exit(1)
note_store = client.get_note_store()