本文整理汇总了Python中astakosclient.AstakosClient类的典型用法代码示例。如果您正苦于以下问题:Python AstakosClient类的具体用法?Python AstakosClient怎么用?Python AstakosClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AstakosClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: retrieve_uuids
def retrieve_uuids(token, displaynames, return_dict=False, fail_silently=True):
astakos = AstakosClient(token, ASTAKOS_AUTH_URL, retry=2, use_pool=True, logger=logger)
catalog = astakos.get_uuids(displaynames) or {}
missing = list(set(displaynames) - set(catalog))
if missing and not fail_silently:
raise ItemNotExists("Unknown uuids: %s" % ", ".join(missing))
return catalog if return_dict else [catalog.get(i) for i in displaynames]
示例2: test_reject_commission
def test_reject_commission(self):
"""Test function call of reject_commission"""
global token, auth_url
try:
client = AstakosClient(token['id'], auth_url)
client.reject_commission(57)
except Exception as err:
self.fail("Shouldn't raise Exception %s" % err)
示例3: get_pithos_usage
def get_pithos_usage(token):
"""Get Pithos Usage from astakos."""
astakos = AstakosClient(ASTAKOS_BASE_URL, retry=2, use_pool=True,
logger=logger)
quotas = astakos.get_quotas(token)['system']
pithos_resources = [r['name'] for r in resources]
map(quotas.pop, filter(lambda k: k not in pithos_resources, quotas.keys()))
return quotas.popitem()[-1] # assume only one resource
示例4: _auth_user
def _auth_user(self, pool):
global token, endpoints_with_info, auth_url
try:
client = AstakosClient(token['id'], auth_url, use_pool=pool)
auth_info = client.authenticate()
except Exception as err:
self.fail("Shouldn't raise an Exception: %s" % err)
self.assertEqual(endpoints_with_info, auth_info)
示例5: retrieve_displaynames
def retrieve_displaynames(token, uuids, return_dict=False, fail_silently=True):
astakos = AstakosClient(ASTAKOS_BASE_URL, retry=2, use_pool=True,
logger=logger)
catalog = astakos.get_usernames(token, uuids) or {}
missing = list(set(uuids) - set(catalog))
if missing and not fail_silently:
raise ItemNotExists('Unknown displaynames: %s' % ', '.join(missing))
return catalog if return_dict else [catalog.get(i) for i in uuids]
示例6: _invalid_url
def _invalid_url(self, pool):
global token, auth_url
try:
client = AstakosClient(token['id'], auth_url, use_pool=pool)
client._call_astakos("/astakos/api/misspelled")
except NotFound:
pass
except Exception, e:
self.fail("Got \"%s\" instead of 404" % e)
示例7: test_get_resources
def test_get_resources(self):
"""Test function call of get_resources"""
global resources, auth_url, token
try:
client = AstakosClient(token['id'], auth_url, retry=1)
result = client.get_resources()
except Exception as err:
self.fail("Shouldn't raise Exception %s" % err)
self.assertEqual(resources, result)
示例8: test_get_quotas
def test_get_quotas(self):
"""Test function call of get_quotas"""
global quotas, token, auth_url
try:
client = AstakosClient(token['id'], auth_url)
result = client.get_quotas()
except Exception as err:
self.fail("Shouldn't raise Exception %s" % err)
self.assertEqual(quotas, result)
示例9: test_get_pending_commissions
def test_get_pending_commissions(self):
"""Test function call of get_pending_commissions"""
global token, pending_commissions, auth_url
try:
client = AstakosClient(token['id'], auth_url)
response = client.get_pending_commissions()
except Exception as err:
self.fail("Shouldn't raise Exception %s" % err)
self.assertEqual(response, pending_commissions)
示例10: test_resolve_commissions
def test_resolve_commissions(self):
"""Test function call of resolve_commissions"""
global token, auth_url
try:
client = AstakosClient(token['id'], auth_url)
result = client.resolve_commissions([56, 57], [56, 58, 59])
except Exception as err:
self.fail("Shouldn't raise Exception %s" % err)
self.assertEqual(result, resolve_commissions_rep)
示例11: test_username
def test_username(self):
"""Test get_username"""
global token, user, auth_url
try:
client = AstakosClient(token['id'], auth_url,
use_pool=False, retry=2)
info = client.get_username(user['id'])
except Exception, e:
self.fail("Shouldn't raise an Exception: %s" % e)
示例12: test_get_uuid
def test_get_uuid(self):
"""Test get_uuid"""
global token, user, auth_url
try:
client = AstakosClient(token['id'], auth_url, retry=1)
catalog = client.get_uuids([user['name']])
except:
self.fail("Shouldn't raise an Exception")
self.assertEqual(catalog[user['name']], user['id'])
示例13: user_for_token
def user_for_token(token, astakos_auth_url, logger=None):
if token is None:
return None
client = AstakosClient(token, astakos_auth_url,
retry=2, use_pool=True, logger=logger)
try:
return client.authenticate()
except Unauthorized:
return None
示例14: retrieve_uuid
def retrieve_uuid(token, displayname):
if is_uuid(displayname):
return displayname
astakos = AstakosClient(token, ASTAKOS_AUTH_URL, retry=2, use_pool=True, logger=logger)
try:
uuid = astakos.get_uuid(displayname)
except NoUUID:
raise ItemNotExists(displayname)
return uuid
示例15: test_get_commission_info
def test_get_commission_info(self):
"""Test function call of get_commission_info"""
global token, commission_description, auth_url
try:
client = AstakosClient(token['id'], auth_url,
use_pool=True, pool_size=2)
response = client.get_commission_info(57)
except Exception as err:
self.fail("Shouldn't raise Exception %s" % err)
self.assertEqual(response, commission_description)