本文整理匯總了Python中pyesgf.search.SearchConnection.get_shard_list方法的典型用法代碼示例。如果您正苦於以下問題:Python SearchConnection.get_shard_list方法的具體用法?Python SearchConnection.get_shard_list怎麽用?Python SearchConnection.get_shard_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyesgf.search.SearchConnection
的用法示例。
在下文中一共展示了SearchConnection.get_shard_list方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: node_info
# 需要導入模塊: from pyesgf.search import SearchConnection [as 別名]
# 或者: from pyesgf.search.SearchConnection import get_shard_list [as 別名]
def node_info(request):
if request.method == 'POST':
''' For demo purposes this is loading a local file '''
try:
from xml.etree.ElementTree import parse
tree = parse('scripts/registration.xml')
root = tree.getroot()
name = json.loads(request.body)['node']
response = {}
for node in root:
if node.attrib['shortName'] == name:
response['org'] = node.attrib['organization']
response['namespace'] = node.attrib['namespace']
response['email'] = node.attrib['supportEmail']
response['ip'] = node.attrib['ip']
response['longName'] = node.attrib['longName']
response['version'] = node.attrib['version']
response['shortName'] = name
response['adminPeer'] = node.attrib['adminPeer']
response['hostname'] = node.attrib['hostname']
for child in list(node):
if child.tag[-len('AuthorizationService'):] == "AuthorizationService":
response['authService'] = child.attrib["endpoint"]
if child.tag[-len('GeoLocation'):] == "GeoLocation":
response['location'] = child.attrib["city"]
if child.tag[-len('Metrics'):] == "Metrics":
for gchild in list(child):
if gchild.tag[-len('DownloadedData'):] == "DownloadedData":
response['dataDownCount'] = gchild.attrib['count']
response['dataDownSize'] = gchild.attrib['size']
response['dataDownUsers'] = gchild.attrib['users']
if gchild.tag[-len('RegisteredUsers'):] == "RegisteredUsers":
response['registeredUsers'] = gchild.attrib['count']
from pyesgf.search import SearchConnection
print 'attempting to connect to ' + 'http://' + response['hostname'] + 'esg-search/'
conn = SearchConnection('http://' + response['hostname'] + '/esg-search/', distrib=True)
try:
conn.get_shard_list()
response['status'] = 'up'
except Exception as e:
print repr(e)
response['status'] = 'down'
return HttpResponse(json.dumps(response))
except Exception as e:
import traceback
print '1', e.__doc__
print '2', sys.exc_info()
print '3', sys.exc_info()[0]
print '4', sys.exc_info()[1]
print '5', traceback.tb_lineno(sys.exc_info()[2])
ex_type, ex, tb = sys.exc_info()
print '6', traceback.print_tb(tb)
return HttpResponse(status=500)
elif request.method == 'POST':
print "Unexpected POST request"
return HttpResponse(status=500)