当前位置: 首页>>代码示例>>Python>>正文


Python pycurl_manager.RequestHandler类代码示例

本文整理汇总了Python中WMCore.Services.pycurl_manager.RequestHandler的典型用法代码示例。如果您正苦于以下问题:Python RequestHandler类的具体用法?Python RequestHandler怎么用?Python RequestHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RequestHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getSpec

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)
开发者ID:vkuznet,项目名称:WMCore,代码行数:8,代码来源:RequestInfo.py

示例2: findParent

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)]
开发者ID:vkuznet,项目名称:WMCore,代码行数:8,代码来源:RequestInfo.py

示例3: getWorkflows

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', [])
开发者ID:amaltaro,项目名称:WMCore,代码行数:9,代码来源:Common.py

示例4: getNodes

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]
开发者ID:vkuznet,项目名称:WMCore,代码行数:9,代码来源:SiteInfo.py

示例5: getWorkflow

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', [])
开发者ID:amaltaro,项目名称:WMCore,代码行数:9,代码来源:Common.py

示例6: getRequest

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
开发者ID:amaltaro,项目名称:WMCore,代码行数:10,代码来源:Common.py

示例7: getNodesForId

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))
开发者ID:amaltaro,项目名称:WMCore,代码行数:10,代码来源:Common.py

示例8: getNodeQueues

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
开发者ID:vkuznet,项目名称:WMCore,代码行数:13,代码来源:SiteInfo.py

示例9: workqueueRequests

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
开发者ID:amaltaro,项目名称:WMCore,代码行数:14,代码来源:RequestInfo.py

示例10: MicroServiceTest

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'])
开发者ID:amaltaro,项目名称:WMCore,代码行数:45,代码来源:MicroService_t.py

示例11: setUp

    def setUp(self):
        "initialization"
        self.mgr = RequestHandler()
        self.ckey = os.path.join(os.environ['HOME'], '.globus/userkey.pem')
        self.cert = os.path.join(os.environ['HOME'], '.globus/usercert.pem')

        self.cricheader = 'Date: Tue, 06 Nov 2018 14:50:29 GMT\r\nServer: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5 mod_gridsite/2.3.4\r\nVary: Cookie\r\nX-Frame-Options: SAMEORIGIN\r\nSet-Cookie: sessionid=bc1xu8zi5rbbsd5fgjuklb2tk2r3f6tw; expires=Sun, 11-Nov-2018 14:50:29 GMT; httponly; Max-Age=432000; Path=/\r\nContent-Length: 32631\r\nContent-Type: application/json\r\n\r\n'
        self.dbsheader = 'Date: Tue, 06 Nov 2018 14:39:07 GMT\r\nServer: Apache\r\nCMS-Server-Time: D=1503 t=1541515147806112\r\nTransfer-Encoding: chunked\r\nContent-Type: text/html\r\n\r\n'
        self.HTTPheader = 'Date: Tue, 06 Nov 2018 14:50:29 GMT\r\nServer: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5 mod_gridsite/2.3.4\r\nVary: Cookie\r\nX-Frame-Options: SAMEORIGIN\r\nSet-Cookie: GRIDHTTP_PASSCODE=2c6da9c96efa2ad0farhda; domain=cms-cric.cern.ch; path=/; secure\r\nContent-Length: 32631\r\nContent-Type: application/json\r\n\r\n'
开发者ID:vkuznet,项目名称:WMCore,代码行数:9,代码来源:pycurl_manager_t.py

示例12: alterSubscription

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
开发者ID:amaltaro,项目名称:WMCore,代码行数:19,代码来源:Common.py

示例13: getDataFromURL

def getDataFromURL(url, proxyfilename = None):
    """
    Read the content of a URL and return it as a string.
    Type of content should not matter, it can be a json file or a tarball for example.

    url: the link you would like to retrieve
    proxyfilename: the x509 proxy certificate to be used in case auth is required

    Returns binary data encoded as a string, which can be later processed
    according to what kind of content it represents.
    """

    # Get rid of unicode which may cause problems in pycurl
    stringUrl = url.encode('ascii')

    reqHandler = RequestHandler()
    _, data = reqHandler.request(url=stringUrl, params={}, ckey=proxyfilename,
                                 cert=proxyfilename,
                                 capath=HTTPRequests.getCACertPath())

    return data
开发者ID:belforte,项目名称:CRABClient,代码行数:21,代码来源:UserUtilities.py

示例14: agentsSites

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
开发者ID:vkuznet,项目名称:WMCore,代码行数:22,代码来源:SiteInfo.py

示例15: setUp

 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()
开发者ID:amaltaro,项目名称:WMCore,代码行数:15,代码来源:MicroService_t.py


注:本文中的WMCore.Services.pycurl_manager.RequestHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。