本文整理汇总了Python中rucio.client.Client.list_accounts方法的典型用法代码示例。如果您正苦于以下问题:Python Client.list_accounts方法的具体用法?Python Client.list_accounts怎么用?Python Client.list_accounts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rucio.client.Client
的用法示例。
在下文中一共展示了Client.list_accounts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: finger
# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import list_accounts [as 别名]
def finger(self, userName):
try:
# get rucio API
client = RucioClient()
userInfo = None
retVal = False
for i in client.list_accounts(account_type='USER',identity=userName):
userInfo = {'nickname':i['account'],
'email':i['email']}
break
if userInfo == None:
# remove /CN=\d
userName = re.sub('(/CN=\d+)+$','',userName)
for i in client.list_accounts(account_type='USER',identity=userName):
userInfo = {'nickname':i['account'],
'email':i['email']}
break
if userInfo is not None:
retVal = True
except:
errtype, errvalue = sys.exc_info()[:2]
errMsg = '{0} {1}'.format(errtype.__name__, errvalue)
userInfo = errMsg
return retVal,userInfo
示例2: ruciowrapper
# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import list_accounts [as 别名]
class ruciowrapper(object):
if 'RUCIO_ACCOUNT' not in os.environ:
os.environ['RUCIO_ACCOUNT'] = get_rucio_account()
if 'X509_USER_PROXY' not in os.environ:
os.environ['X509_USER_PROXY'] = get_x509_proxy()
client = None
def __init__(self):
try:
self.client = Client()
except Exception as e:
logging.error('Failed to initiate Rucio client:' + str(e))
def getRucioAccountByDN(self, DN):
values = ['rucio_account', 'create_time']
accounts = []
accounts.extend(RucioAccounts.objects.filter(certificatedn=DN).values(*values))
accountExists = len(accounts)
if accountExists == 0 or (timezone.now() - accounts[0]['create_time']) > timedelta(days=7):
if not self.client is None:
try:
accounts = [account['account'] for account in self.client.list_accounts(account_type='USER',identity=DN)]
except Exception as e:
logging.error('Failed to get accounts' + str(e))
return accounts
if len(accounts) > 0:
if (accountExists == 0):
RucioAccounts.objects.filter(certificatedn=DN).delete()
for account in accounts:
accountRow = RucioAccounts(
rucio_account = account,
certificatedn = DN,
create_time = timezone.now().date(),
)
accountRow.save()
else:
accounts = [account['rucio_account'] for account in accounts]
return accounts