本文整理汇总了Python中b2handle.handleclient.EUDATHandleClient.instantiate_for_read_access方法的典型用法代码示例。如果您正苦于以下问题:Python EUDATHandleClient.instantiate_for_read_access方法的具体用法?Python EUDATHandleClient.instantiate_for_read_access怎么用?Python EUDATHandleClient.instantiate_for_read_access使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b2handle.handleclient.EUDATHandleClient
的用法示例。
在下文中一共展示了EUDATHandleClient.instantiate_for_read_access方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_issue_pid
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_for_read_access [as 别名]
def check_issue_pid(self):
# Checking PID HANDLE
print('checkin PIDs')
sleep(5)
handle_client = EUDATHandleClient.instantiate_for_read_access()
self.uid = self.issue['uid']
for line in self.dsets:
print('CHECKING {} ERRATA IDS'.format(line))
exists = False
dataset = line.split('#')
dset_id = dataset[0]
dset_version = dataset[1]
hash_basis = dset_id+'.v'+dset_version
hash_basis_utf8 = hash_basis.encode('utf-8')
handle_string = uuid.uuid3(uuid.NAMESPACE_URL, hash_basis_utf8)
encoded_dict = handle_client.retrieve_handle_record(prefix + str(handle_string))
if encoded_dict is not None:
handle_record = {k.decode('utf8'): v.decode('utf8') for k, v in encoded_dict.items()}
if 'ERRATA_IDS' in handle_record.keys():
for uid in str(handle_record['ERRATA_IDS']).split(';'):
if uid == self.uid:
exists = True
break
if not exists:
print('An error occurred updating handle.')
return exists
示例2: _check_handle_status
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_for_read_access [as 别名]
def _check_handle_status(dataset_id):
"""Checks handle exists or not.
:returns: Flag indicating whether handle status is such that it requires fiurther processing
:rtype: bool
"""
# Get handle information.
handle_string = resolve_input(dataset_id)
handle_client = EUDATHandleClient.instantiate_for_read_access()
encoded_dict = handle_client.retrieve_handle_record(handle_string)
# Error if not found.
if encoded_dict is None:
raise exceptions.HandleMismatch('Dataset {} has no published pid handle'.format(dataset_id))
# Reformat handle information.
handle_record = {k.decode('utf8'): v.decode('utf8') for k, v in encoded_dict.items()}
# Error if handle has no test value.
if '_TEST' not in handle_record.keys():
logger.log_pid('Dataset handle does not have test value, assuming not test...')
# raise exceptions.HandleMismatch('TEST VALUE WAS NOT FOUND IN HANDLE, ABORTING....')
else:
# Error if handle record value.
if handle_record['_TEST'].lower() != str(config.pid.is_test).lower():
raise exceptions.HandleMismatch('Dataset {} has mismatched test status [{}] with pid connector'.format(dataset_id, handle_record['_TEST']))
示例3: test_instantiate_for_read_access
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_for_read_access [as 别名]
def test_instantiate_for_read_access(self):
"""Testing if instantiating with default handle server works
and if a handle is correctly retrieved. """
# Create client instance with username and password
inst = EUDATHandleClient.instantiate_for_read_access(HTTPS_verify=self.https_verify)
rec = self.inst.retrieve_handle_record_json(self.handle)
self.assertIsInstance(inst, EUDATHandleClient)
self.assertIn("handle", rec, 'Response lacks "handle".')
self.assertIn("responseCode", rec, 'Response lacks "responseCode".')
示例4: main
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_for_read_access [as 别名]
def main():
""" Main function to test the script """
client = EUDATHandleClient.instantiate_for_read_access()
value = client.get_value_from_handle("11100/33ac01fc-6850-11e5-b66e-e41f13eb32b2", "URL")
print value
result = client.search_handle("irods://data.repo.cineca.it:1247/CINECA01/home/cin_staff/rmucci00/DSI_Test/test.txt")
print result
get_pid_info(pid='11100/0beb6af8-cbe5-11e3-a9da-e41f13eb41b2')
示例5: harvest_errata_information
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_for_read_access [as 别名]
def harvest_errata_information(input_handle_string):
"""Given a handle, this will harvest all the errata data related to that handle as well as the previous versions.
:param input_handle_string: Handle identifier
:return: errata information, dset/file_id
"""
tick = time()
logger.log_pid("--CREATING HANDLE CLIENT--")
handle_client = EUDATHandleClient.instantiate_for_read_access()
logger.log_pid("--HANDLE CLIENT CREATED--")
logger.log_pid("----------------------------------BEGIN ISSUE TRACKING----------------------------------")
handle = get_handle_by_handle_string(input_handle_string, handle_client)
list_of_uids, incomplete_search = crawler(handle, handle_client)
logger.log_pid("ELAPSED TIME TILL COMPLETION : " + str(time()-tick) + " SECONDS")
logger.log_pid("-----------------------------------END ISSUE TRACKING-----------------------------------")
logger.log_pid("LIST OF UIDS GENERATED IS...")
logger.log_pid(list_of_uids)
return list_of_uids, incomplete_search
示例6: harvest_simple_errata
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_for_read_access [as 别名]
def harvest_simple_errata(input_handle_string):
"""
A simplified version of the harvest original implementation.
:param input_handle_string: pid handle string
:return: errata_id list, empty if no errata is found.
"""
output = []
logger.log_pid("--CREATING HANDLE CLIENT--")
handle_client = EUDATHandleClient.instantiate_for_read_access()
logger.log_pid("--SUCCESSFULLY CREATED CLIENT--")
logger.log_pid("--RETRIEVING HANDLE FROM PID SERVER--")
handle = get_handle_by_handle_string(input_handle_string, handle_client)
if handle is not None:
if ERRATA_IDS in handle.keys():
output = str(handle[ERRATA_IDS].split(";"))
drs_id = handle[DRS]
version = handle[VERSION]
else:
logger.log_pid("--HANDLE NOT FOUND IN PID SERVER--")
return input_handle_string, drs_id, version, output, len(output) >= 1, len(drs_id) > 1
# Dataset A
# harvest_errata_information('21.14100/aae01ba2-8436-378d-84ed-5a06b9fbee46')
# Dataset B:
# harvest_errata_information('21.14100/37043d8e-ac5e-3843-a019-c03017cc68aa')
# Dataset C:
# harvest_errata_information('21.14100/e0560a9d-2227-3175-b943-fc26c427a923')
# Dataset D:
# harvest_errata_information('21.14100/bc3d4e81-bfbd-3a3f-a99f-4a2ec64b5962')
# temperature file
# harvest_errata_information('21.14100/d9053480-0e0d-11e6-a148-3e1d05defe78')
# rainfall file
# harvest_errata_information('21.14100/28ju73be-0e10-11e6-a148-a7751ce7ec0c')
# rainfall_1 file
# harvest_errata_information('21.14100/4ba213fc-f688-3d58-bd96-d984bb00f1d5')
# print(harvest_simple_errata('21.14100/4ba213fc-f688-3d58-bd96-d984bb00f1d5'))
示例7: check_drs
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_for_read_access [as 别名]
from b2handle.handleclient import EUDATHandleClient
import uuid
import logging
import esgfpid
handle_client = EUDATHandleClient.instantiate_for_read_access()
def check_drs(drs_id):
drs_id = drs_id.split('#')
prefix = '21.14100/'
hash_basis = drs_id[0]+'.v'+drs_id[1]
hash_basis_utf8 = hash_basis.encode('utf-8')
handle_string = uuid.uuid3(uuid.NAMESPACE_URL, hash_basis_utf8)
encoded_dict = handle_client.retrieve_handle_record(prefix + str(handle_string))
if encoded_dict is not None:
return True
else:
print('Handle not found.')
return False
def clear_handle(drs_id, connector):
drs_id = drs_id.split('#')
prefix = '21.14100/'
hash_basis = drs_id[0]+'.v'+drs_id[1]
hash_basis_utf8 = hash_basis.encode('utf-8')
handle_string = uuid.uuid3(uuid.NAMESPACE_URL, hash_basis_utf8)
encoded_dict = handle_client.retrieve_handle_record(prefix + str(handle_string))
if encoded_dict is not None:
handle_record = {k.decode('utf8'): v.decode('utf8') for k, v in encoded_dict.items()}
示例8: test_instantiate_for_read_access
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import instantiate_for_read_access [as 别名]
def test_instantiate_for_read_access(self):
"""Testing if instantiating with default handle server works. """
# Create client instance with username and password
inst = EUDATHandleClient.instantiate_for_read_access()
self.assertIsInstance(inst, EUDATHandleClient)