示例#1
0
文件: cms.py 项目: huohuo21/WMCore
 def data(self):
     "Fetch data from tag collector or local cache"
     tstamp = time.time()
     if  os.path.isfile(self.cache):
         data = open(self.cache, 'r').read()
     else:
         params = {}
         data = getdata(self.url, params, verbose=1, jsondecoder=False)
         with open(self.cache, 'w') as ostream:
             ostream.write(data)
     pkey = 'architecture'
     for row in xml_parser(data, pkey):
         yield row[pkey]
示例#2
0
 def data(self):
     "Fetch data from tag collector or local cache"
     tstamp = time.time()
     if os.path.isfile(self.cache):
         data = open(self.cache, 'r').read()
     else:
         params = {}
         data = getdata(self.url, params, verbose=1, jsondecoder=False)
         with open(self.cache, 'w') as ostream:
             ostream.write(data)
     pkey = 'architecture'
     for row in xml_parser(data, pkey):
         yield row[pkey]
示例#3
0
 def request(self, **kwargs):
     "Get data example and expose it as json"
     dataset = kwargs.get('uinput', '')
     if not dataset:
         return {'error': 'no input dataset'}
     url = 'https://cmsweb.cern.ch/reqmgr/rest/outputdataset/%s' % dataset
     params = {}
     wdata = getdata(url, params)
     wdict = dict(date=time.ctime(), team='Team-A', status='Running', ID=genid(wdata))
     winfo = self.templatepage('workflow', wdict=wdict,
                               dataset=dataset, code=pprint.pformat(wdata))
     content = self.templatepage('search', content=winfo)
     return self.abs_page('request', content)
示例#4
0
 def getTeams(self):
     "Helper function to get teams from wmstats or local cache"
     teams = self.team_cache
     url = '%s/data/teams' % self.wmstatsurl
     params = {}
     headers = {'Accept': 'application/json'}
     try:
         data = getdata(url, params, headers)
         if 'error' in data:
             print("WARNING: fail to get teams from %s" % url)
             print(data)
         teams = data.get('result', [])
         self.team_cache = teams
     except Exception as exp:
         print("WARNING: fail to get teams from %s" % url)
         print(str(exp))
     return teams
示例#5
0
 def getTeams(self):
     "Helper function to get teams from wmstats or local cache"
     teams = self.team_cache
     url = '%s/data/teams' % self.wmstatsurl
     params = {}
     headers = {'Accept':'application/json'}
     try:
         data = getdata(url, params, headers)
         if  'error' in data:
             print("WARNING: fail to get teams from %s" % url)
             print(data)
         teams = data.get('result', [])
         self.team_cache = teams
     except Exception as exp:
         print("WARNING: fail to get teams from %s" % url)
         print(str(exp))
     return teams
示例#6
0
 def request(self, **kwargs):
     "Get data example and expose it as json"
     dataset = kwargs.get('uinput', '')
     if not dataset:
         return {'error': 'no input dataset'}
     url = 'https://cmsweb.cern.ch/reqmgr/rest/outputdataset/%s' % dataset
     params = {}
     wdata = getdata(url, params)
     wdict = dict(date=time.ctime(),
                  team='Team-A',
                  status='Running',
                  ID=genid(wdata))
     winfo = self.templatepage('workflow',
                               wdict=wdict,
                               dataset=dataset,
                               code=pprint.pformat(wdata))
     content = self.templatepage('search', content=winfo)
     return self.abs_page('request', content)