本文整理汇总了Python中rucio.client.Client.set_status方法的典型用法代码示例。如果您正苦于以下问题:Python Client.set_status方法的具体用法?Python Client.set_status怎么用?Python Client.set_status使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rucio.client.Client
的用法示例。
在下文中一共展示了Client.set_status方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: closeDataset
# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import set_status [as 别名]
def closeDataset(self,dsn):
# register dataset
client = RucioClient()
try:
scope,dsn = self.extract_scope(dsn)
client.set_status(scope,dsn,open=False)
except (UnsupportedOperation,DataIdentifierNotFound):
pass
return True
示例2: registerDataset
# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import set_status [as 别名]
def registerDataset(self,dsn,lfns=[],guids=[],sizes=[],checksums=[],lifetime=None,scope=None,metadata=None):
presetScope = scope
files = []
for lfn, guid, size, checksum in zip(lfns, guids, sizes, checksums):
if lfn.find(':') > -1:
s, lfn = lfn.split(':')[0], lfn.split(':')[1]
else:
s = scope
file = {'scope': s, 'name': lfn, 'bytes': size, 'meta': {'guid': guid}}
if checksum.startswith('md5:'):
file['md5'] = checksum[4:]
elif checksum.startswith('ad:'):
file['adler32'] = checksum[3:]
files.append(file)
# register dataset
client = RucioClient()
try:
scope,dsn = self.extract_scope(dsn)
if presetScope is not None:
scope = presetScope
client.add_dataset(scope=scope, name=dsn, meta=metadata)
if lifetime != None:
client.set_metadata(scope,dsn,key='lifetime',value=lifetime*86400)
except DataIdentifierAlreadyExists:
pass
# open dataset just in case
try:
client.set_status(scope,dsn,open=True)
except:
pass
# add files
if len(files) > 0:
iFiles = 0
nFiles = 1000
while iFiles < len(files):
tmpFiles = files[iFiles:iFiles+nFiles]
try:
client.add_files_to_dataset(scope=scope,name=dsn,files=tmpFiles, rse=None)
except FileAlreadyExists:
for f in tmpFiles:
try:
client.add_files_to_dataset(scope=scope, name=dsn, files=[f], rse=None)
except FileAlreadyExists:
pass
iFiles += nFiles
vuid = hashlib.md5(scope+':'+dsn).hexdigest()
vuid = '%s-%s-%s-%s-%s' % (vuid[0:8], vuid[8:12], vuid[12:16], vuid[16:20], vuid[20:32])
duid = vuid
return {'duid': duid, 'version': 1, 'vuid': vuid}