本文整理匯總了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