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


Python Service.Service类代码示例

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


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

示例1: __init__

    def __init__(self, dict = {}):
        """
        """
        dict.setdefault('secure', False)
        if not dict.has_key('endpoint'):
            dict['endpoint'] = "%cmsweb.cern.ch/workqueue/" % \
                                ((dict['secure'] and "https://" or "http://"))
        if dict.has_key('cachepath'):
            pass
        elif os.getenv('WORKQUEUE_CACHE_DIR'):
            dict['cachepath'] = os.getenv('WORKQUEUE_CACHE_DIR') + '/.workqueue_cache'
        elif os.getenv('HOME'):
            dict['cachepath'] = os.getenv('HOME') + '/.workqueue_cache'
        else:
            dict['cachepath'] = '/tmp/.workqueue_' + pwd.getpwuid(os.getuid())[0]
        if not os.path.isdir(dict['cachepath']):
            os.makedirs(dict['cachepath'])
        if 'logger' not in dict.keys():
            logging.basicConfig(level = logging.DEBUG,
                    format = '%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                    datefmt = '%m-%d %H:%M',
                    filename = dict['cachepath'] + '/jsonparser.log',
                    filemode = 'w')
            dict['logger'] = logging.getLogger('WorkQueueParser')

        dict.setdefault("accept_type", "application/json+thunker")
        dict.setdefault("content_type", "application/json")
        
        self.encoder = JsonWrapper.dumps
        self.decoder = self.jsonThunkerDecoder
        
        Service.__init__(self, dict)
开发者ID:PerilousApricot,项目名称:CRAB2,代码行数:32,代码来源:WorkQueue.py

示例2: __init__

    def __init__(self, config={}):
        config = dict(config) ### copy dict since mutables are shared between instances
        config['endpoint'] = "https://cmsweb.cern.ch/sitedb/data/prod/"
        config['accept_type'] = "application/json"
        config['content_type'] = "application/json"

        if os.getenv('CMS_SITEDB_CACHE_DIR'):
            config['cachepath'] = os.getenv('CMS_SITEDB_CACHE_DIR') + '/.cms_sitedbcache'
        elif os.getenv('HOME'):
            config['cachepath'] = os.getenv('HOME') + '/.cms_sitedbcache'
        else:
            import pwd
            config['cachepath'] = '/tmp/sitedbjson_' + pwd.getpwuid(os.getuid())[0]

        if not os.path.isdir(config['cachepath']):
            os.mkdir(config['cachepath'])

        if 'logger' not in config.keys():
            logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                    datefmt='%m-%d %H:%M',
                    filename=config['cachepath'] + '/sitedbjsonparser.log',
                    filemode='w')
            config['logger'] = logging.getLogger('SiteDBParser')

        Service.__init__(self, config)
开发者ID:dmwm,项目名称:WMCore-legacy,代码行数:26,代码来源:SiteDB.py

示例3: __init__

    def __init__(self, dict = {}, secure = False):
        """
        responseType will be either xml or json
        """

        if not dict.has_key('endpoint'):
            #TODO needs to change proper default location
            dict['endpoint'] = "%scmssrv49.fnal.gov:8585/reqMgr/" % \
                                ((secure and "https://" or "http://"))
        if dict.has_key('cachepath'):
            pass
        elif os.getenv('REQUESTMGR_CACHE_DIR'):
            dict['cachepath'] = os.getenv('REQUESTMGR_CACHE_DIR') + '/.requestmgr_cache'
        elif os.getenv('HOME'):
            dict['cachepath'] = os.getenv('HOME') + '/.requestmgr_cache'
        else:
            dict['cachepath'] = '/tmp/.requestmgr_' + pwd.getpwuid(os.getuid())[0]
        if not os.path.isdir(dict['cachepath']):
            os.makedirs(dict['cachepath'])
        if 'logger' not in dict.keys():
            logging.basicConfig(level = logging.DEBUG,
                    format = '%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                    datefmt = '%m-%d %H:%M',
                    filename = dict['cachepath'] + '/jsonparser.log',
                    filemode = 'w')
            dict['logger'] = logging.getLogger('RequestMgrParser')

        dict['accept_type'] = 'text/json'

        Service.__init__(self, dict)
开发者ID:PerilousApricot,项目名称:CRAB2,代码行数:30,代码来源:RequestManager.py

示例4: __init__

 def __init__(self, dict={}, responseType="xml"):
     """
     responseType will be either xml or json
     """
     self.responseType = responseType.lower()
     
     #if self.responseType == 'json':
         #self.parser = JSONParser()
     #elif self.responseType == 'xml':
         #self.parser = XMLParser()
         
     if os.getenv('WMBS_SERV_CACHE_DIR'):
         dict['cachepath'] = os.getenv('WMBS_SERV_CACHE_DIR') + '/.wmbs_service_cache'
     elif os.getenv('HOME'):
         dict['cachepath'] = os.getenv('HOME') + '/.wmbs_service_cache'
     else:
         dict['cachepath'] = '/tmp/wmbs_service_cache_' + pwd.getpwuid(os.getuid())[0]
     if not os.path.isdir(dict['cachepath']):
         os.mkdir(dict['cachepath'])
     if 'logger' not in dict.keys():
         logging.basicConfig(level=logging.DEBUG,
                 format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                 datefmt='%m-%d %H:%M',
                 filename=dict['cachepath'] + '/wmbs_service.log',
                 filemode='w')
         dict['logger'] = logging.getLogger('WMBSParser')
     
     #TODO if service doesn't need to be authorized, have switch to use Service
     Service.__init__(self, dict)
开发者ID:PerilousApricot,项目名称:CRAB2,代码行数:29,代码来源:WMBS.py

示例5: __init__

    def __init__(self, dict = {}, responseType = "json", secure = False):
        """
        responseType will be either xml or json
        """
        self.responseType = responseType.lower()

        dict["timeout"] = 300

        if not dict.has_key('endpoint'):
            dict['endpoint'] = "%scmsweb.cern.ch/phedex/datasvc/%s/prod/" % \
                                ((secure and "https://" or "http://"),
                                 self.responseType)

        if dict.has_key('cachepath'):
            pass
        elif os.getenv('CMS_PHEDEX_CACHE_DIR'):
            dict['cachepath'] = os.getenv('CMS_PHEDEX_CACHE_DIR') + '/.cms_phedexcache'
        elif os.getenv('HOME'):
            dict['cachepath'] = os.getenv('HOME') + '/.cms_phedexcache'
        else:
            dict['cachepath'] = '/tmp/phedex_' + pwd.getpwuid(os.getuid())[0]
        if not os.path.isdir(dict['cachepath']):
            os.makedirs(dict['cachepath'])
        if 'logger' not in dict.keys():
            logging.basicConfig(level = logging.DEBUG,
                    format = '%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                    datefmt = '%m-%d %H:%M',
                    filename = dict['cachepath'] + '/phedexdbjsonparser.log',
                    filemode = 'w')
            dict['logger'] = logging.getLogger('PhEDExParser')

        Service.__init__(self, dict)
开发者ID:PerilousApricot,项目名称:CRAB2,代码行数:32,代码来源:PhEDEx.py

示例6: testStaleCache

 def testStaleCache(self):
     myConfig = {'logger': self.logger,
             'endpoint': 'https://github.com/dmwm',
             'usestalecache': True,
             }
     service = Service(myConfig)
     service.getData('%s/socketresettest' % self.testDir, '/WMCore/blob/master/setup.py#L11')
     self.assertEqual(service['usestalecache'], myConfig['usestalecache'])
开发者ID:vkuznet,项目名称:WMCore,代码行数:8,代码来源:Service_t.py

示例7: __init__

    def __init__(self, dict={}):
        dict['endpoint'] =  dict.get('endpoint', 'https://cmsweb.cern.ch/crabcache/')
        Service.__init__(self, dict)

        if dict.has_key('proxyfilename'):
            #in case there is some code I have not updated in ticket #3780. Should not be required... but...
            self['logger'].warning('The UserFileCache proxyfilename parameter has been replace with the more'
                                   ' general (ckey/cert) pair.')
开发者ID:cinquo,项目名称:WMCore,代码行数:8,代码来源:UserFileCache.py

示例8: testSocketTimeout

 def testSocketTimeout(self):
     myConfig = {'logger': self.logger,
             'endpoint': 'https://github.com/dmwm',
             'cacheduration': None,
             'timeout': 10,
             }
     service = Service(myConfig)
     service.getData('%s/socketresettest' % self.testDir, '/WMCore/blob/master/setup.py#L11')
     self.assertEqual(service['timeout'], myConfig['timeout'])
开发者ID:vkuznet,项目名称:WMCore,代码行数:9,代码来源:Service_t.py

示例9: __init__

 def __init__(self, dict={}):
     try:
         Service.__init__(self, dict)
         self["requests"] = SSLRequests(self["requests"]["host"])
          
     except WMException, ex:
         msg = str(ex)
         self["logger"].exception(msg)
         raise WMException(msg)
开发者ID:PerilousApricot,项目名称:CRAB2,代码行数:9,代码来源:SSLService.py

示例10: testZ_InterruptedConnection

    def testZ_InterruptedConnection(self):
        """
        _InterruptedConnection_

        What happens if we shut down the server while
        the connection is still active?

        Confirm that the cache works as expected
        """

        cherrypy.tree.mount(RegularServer(), "/reg1")
        cherrypy.engine.start()
        FORMAT = '%(message)s'
        logging.basicConfig(format=FORMAT)
        logger = logging.getLogger('john')
        test_dict = {'logger': self.logger,'endpoint':'http://localhost:%i/reg1/regular' % self.port,
                     'usestalecache': False, "cacheduration": 0.005}
        myService = Service(test_dict)
        self.assertRaises(HTTPException, myService.getData, 'foo', 'THISISABADURL')

        data = myService.refreshCache('foo', '')
        dataString = data.read()
        self.assertEqual(dataString, "This is silly.")
        data.close()

        # Now stop the server and confirm that it is down
        cherrypy.server.stop()
        self.assertRaises(socket.error, myService.forceRefresh, 'foo', '')

        # Make sure we can still read from the cache
        data = myService.refreshCache('foo', '')
        dataString = data.read()
        self.assertEqual(dataString, "This is silly.")
        data.close()

        # Mount a backup server
        del cherrypy.tree.apps['/reg1']
        cherrypy.tree.mount(BackupServer(), "/reg1")

        # Expire cache
        time.sleep(30)
        self.assertRaises(socket.error, myService.forceRefresh, 'foo', '')

        # Restart server
        cherrypy.server.start()

        # Confirm new server is in place
        data = myService.refreshCache('foo', '')
        dataString = data.read()
        self.assertEqual(dataString, "This is nuts.")
        data.close()

        cherrypy.engine.exit()
        cherrypy.engine.stop()

        return
开发者ID:zhiwenuil,项目名称:WMCore,代码行数:56,代码来源:Service_t.py

示例11: __init__

    def __init__(self, dict={}):
        dict["endpoint"] = dict.get("endpoint", "https://cmsweb.cern.ch/crabcache/")
        Service.__init__(self, dict)
        self["requests"]["accept_type"] = "application/json"

        if "proxyfilename" in dict:
            # in case there is some code I have not updated in ticket #3780. Should not be required... but...
            self["logger"].warning(
                "The UserFileCache proxyfilename parameter has been replace with the more" " general (ckey/cert) pair."
            )
开发者ID:pietverwilligen,项目名称:WMCore,代码行数:10,代码来源:UserFileCache.py

示例12: __init__

    def __init__(self, url, logger=None):
        params = {}
        params['endpoint'] = url
        params['cacheduration'] = 0
        params['accept_type'] = 'application/json'
        params['content_type'] = 'application/json'
        params['method'] = 'GET'
        params['logger'] = logger if logger else logging.getLogger()

        Service.__init__(self, params)
开发者ID:amaltaro,项目名称:WMCore,代码行数:10,代码来源:Dashboard.py

示例13: testSocketTimeout

 def testSocketTimeout(self):
     dict = {'logger': self.logger,
             'endpoint': 'https://github.com/dmwm',
             'cacheduration': None,
             'timeout': 10,
             }
     service = Service(dict)
     deftimeout = socket.getdefaulttimeout()
     service.getData('%s/socketresettest' % self.testDir, '/WMCore/blob/master/setup.py#L11')
     assert deftimeout == socket.getdefaulttimeout()
开发者ID:yuyiguo,项目名称:WMCore,代码行数:10,代码来源:Service_t.py

示例14: __init__

    def __init__(self, dict={}):
        dict["endpoint"] = dict.get("endpoint", "https://cmsweb.cern.ch/crabcache/")
        Service.__init__(self, dict)

        if dict.has_key("proxyfilename"):
            # in case there is some code I have not updated in ticket #3780. Should not be required... but...
            self["logger"].warning(
                "The UserFileCache proxyfilename parameter has been replace with the more"
                + " general (ckey/cert) pair."
            )
开发者ID:stuartw,项目名称:WMCore,代码行数:10,代码来源:UserFileCache.py

示例15: __init__

    def __init__(self, mydict=None):
        if mydict==None: #dangerous {} default value
            mydict = {}
        mydict['endpoint'] =  mydict.get('endpoint', 'https://cmsweb.cern.ch/crabcache/')
        Service.__init__(self, mydict)
        self['requests']['accept_type'] = 'application/json'

        if 'proxyfilename' in mydict:
            #in case there is some code I have not updated in ticket #3780. Should not be required... but...
            self['logger'].warning('The UserFileCache proxyfilename parameter has been replace with the more'
                                   ' general (ckey/cert) pair.')
开发者ID:BrunoCoimbra,项目名称:WMCore,代码行数:11,代码来源:UserFileCache.py


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