本文整理汇总了Python中WMCore.Services.pycurl_manager.RequestHandler.getdata方法的典型用法代码示例。如果您正苦于以下问题:Python RequestHandler.getdata方法的具体用法?Python RequestHandler.getdata怎么用?Python RequestHandler.getdata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Services.pycurl_manager.RequestHandler
的用法示例。
在下文中一共展示了RequestHandler.getdata方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findParent
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def findParent(dataset):
"Helper function to find a parent of the dataset"
url = '%s/datasetparents' % dbsUrl()
params = {'dataset': dataset}
headers = {'Accept': 'application/json'}
mgr = RequestHandler()
data = mgr.getdata(url, params=params, headers=headers, cert=cert(), ckey=ckey())
return [str(i['parent_dataset']) for i in json.loads(data)]
示例2: getSpec
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def getSpec(request, reqSpecs=None):
"Get request from workload cache"
if reqSpecs and request['RequestName'] in reqSpecs:
return reqSpecs[request['RequestName']]
url = str('%s/%s/spec' % (reqmgrCacheUrl(), request['RequestName']))
mgr = RequestHandler()
data = mgr.getdata(url, params={}, cert=cert(), ckey=ckey())
return pickle.loads(data)
示例3: MicroServiceTest
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
class MicroServiceTest(unittest.TestCase):
"Unit test for MicroService module"
def setUp(self):
"Setup MicroService for testing"
self.app = ServiceManager()
config = TestConfig
manager = 'WMCore_t.Services_t.MicroService_t.MicroService_t.ServiceManager'
config.views.data.manager = manager
config.manager = manager
mount = '/microservice'
self.mgr = RequestHandler()
self.port = config.main.port
self.url = 'http://localhost:%s%s/data' % (self.port, mount)
cherrypy.config["server.socket_port"] = self.port
self.server = RestApiHub(self.app, config, mount)
cherrypy.tree.mount(self.server, mount)
cherrypy.engine.start()
def tearDown(self):
"Tear down MicroService"
cherrypy.engine.exit()
cherrypy.engine.stop()
def postRequest(self, params):
"Perform POST request to our MicroService"
headers = {'Content-type': 'application/json'}
print("### post call %s params=%s headers=%s" % (self.url, params, headers))
data = self.mgr.getdata(self.url, params=params, headers=headers, \
verb='POST', cert=cert(), ckey=ckey())
print("### post call data %s" % data)
return json.loads(data)
def test_getState(self):
"Test function for getting state of the MicroService"
url = '%s/status' % self.url
data = self.mgr.getdata(url, params={})
state = "bla"
data = {"request":{"state": state}}
self.postRequest(data)
data = self.mgr.getdata(url, params={})
data = json.loads(data)
print("### url=%s, data=%s" % (url, data))
for row in data['result']:
if 'state' in row:
self.assertEqual(state, row['state'])
示例4: getNodes
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def getNodes(kind):
"Get list of PhEDEx nodes"
params = {}
headers = {'Accept': 'application/json'}
url = '%s/nodes' % phedexUrl()
mgr = RequestHandler()
data = mgr.getdata(url, params=params, headers=headers, ckey=ckey(), cert=cert())
nodes = json.loads(data)['phedex']['node']
return [node['name'] for node in nodes if node['kind'] == kind]
示例5: getWorkflows
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def getWorkflows(state):
"Get list of workflows from ReqMgr2 data-service"
url = '%s/data/request' % reqmgrUrl()
headers = {'Accept': 'application/json'}
params = {'status': state}
mgr = RequestHandler()
res = mgr.getdata(url, params=params, headers=headers, ckey=ckey(), cert=cert())
data = json.loads(res)
return data.get('result', [])
示例6: getWorkflow
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def getWorkflow(requestName):
"Get list of workflow info from ReqMgr2 data-service for given request name"
headers = {'Accept': 'application/json'}
params = {}
url = '%s/data/request/%s' % (reqmgrUrl(), requestName)
mgr = RequestHandler()
res = mgr.getdata(url, params=params, headers=headers, ckey=ckey(), cert=cert())
data = json.loads(res)
return data.get('result', [])
示例7: getRequest
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def getRequest(url, params):
"Helper function to GET data from given URL"
mgr = RequestHandler()
headers = {'Accept': 'application/json'}
verbose = 0
if 'verbose' in params:
verbose = params['verbose']
del params['verbose']
data = mgr.getdata(url, params, headers, ckey=ckey(), cert=cert(), verbose=verbose)
return data
示例8: getNodesForId
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def getNodesForId(phedexid):
"Helper function to get nodes for given phedex id"
url = '%s/requestlist' % phedexUrl()
params = {'request': str(phedexid)}
headers = {'Accept': 'application/json'}
mgr = RequestHandler()
data = mgr.getdata(url, params, headers, ckey=ckey(), cert=cert())
items = json.loads(data)['phedex']['request']
nodes = [n['name'] for i in items for n in i['node']]
return list(set(nodes))
示例9: getNodeQueues
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def getNodeQueues():
"Helper function to fetch nodes usage from PhEDEx data service"
headers = {'Accept': 'application/json'}
params = {}
mgr = RequestHandler()
url = '%s/nodeusagehistory' % phedexUrl()
res = mgr.getdata(url, params=params, headers=headers, ckey=ckey(), cert=cert())
data = json.loads(res)
ret = defaultdict(int)
for node in data['phedex']['node']:
for usage in node['usage']:
ret[node['name']] += int(usage['miss_bytes'] / 1023.**4) #in TB
return ret
示例10: workqueueRequests
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def workqueueRequests(state=None):
"Helper functions to get requests from WorkQueue"
url = workqueueView('jobsByRequest')
if state:
pass # we may need to use state when we'll query WorkQueue
params = {}
headers = {'Accept': 'application/json'}
mgr = RequestHandler()
data = mgr.getdata(url, params=params, headers=headers, cert=cert(), ckey=ckey())
data = json.loads(data)
rdict = {}
for row in data.get('rows', []):
rdict[row['key']] = row['value']
return rdict
示例11: alterSubscription
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def alterSubscription(phedexid, decision, comments, nodes=None):
"Helper function to alter subscriptions for given phedex id and nodes"
mgr = RequestHandler()
headers = {'Accept': 'application/json'}
nodes = nodes if nodes else getNodesForId(phedexid)
params = {
'decision': decision,
'request': phedexid,
'node': ','.join(nodes),
'comments': comments
}
url = '%s/updaterequest'
data = mgr.getdata(url, params, headers, ckey=ckey(), cert=cert(), verb='POST')
result = json.loads(data)
if not result:
return False
if 'already' in result:
return True
return result
示例12: agentsSites
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def agentsSites(url):
"Return list of sites known in CMS WMAgents"
sites_ready_in_agent = set()
headers = {'Accept': 'application/json'}
params = {}
mgr = RequestHandler()
res = mgr.getdata(url, params=params, headers=headers, ckey=ckey(), cert=cert())
data = json.loads(res)
agents = {}
for r in [i['value'] for i in data['rows']]:
team = r['agent_team']
if team != 'production':
continue
agents.setdefault(team, []).append(r)
for team, agents in agents.items():
for agent in agents:
if agent['status'] != 'ok':
continue
for site, sinfo in agent['WMBS_INFO']['thresholds'].iteritems():
if sinfo['state'] in ['Normal']:
sites_ready_in_agent.add(site)
return sites_ready_in_agent
示例13: getdata
# 需要导入模块: from WMCore.Services.pycurl_manager import RequestHandler [as 别名]
# 或者: from WMCore.Services.pycurl_manager.RequestHandler import getdata [as 别名]
def getdata(url, params, headers=None):
"Helper function to get data from the service"
ckey, cert = getKeyCertFromEnv()
mgr = RequestHandler()
res = mgr.getdata(url, params=params, headers=headers, ckey=ckey, cert=cert)
return json.loads(res)