3 # This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 from urllib2 import Request, urlopen, URLError
12 import reportingConf as conf
15 def getLogger(module):
16 logFormatter = logging.Formatter("%(asctime)s [" +
18 "] [%(levelname)-5.5s] %(message)s")
19 logger = logging.getLogger()
21 fileHandler = logging.FileHandler("{0}/{1}".format('.', conf.LOG_FILE))
22 fileHandler.setFormatter(logFormatter)
23 logger.addHandler(fileHandler)
25 consoleHandler = logging.StreamHandler()
26 consoleHandler.setFormatter(logFormatter)
27 logger.addHandler(consoleHandler)
28 logger.setLevel(conf.LOG_LEVEL)
32 def getScenarioStatus(installer, version):
33 url = (conf.URL_BASE + "?case=" + "scenario_status" +
34 "&installer=" + installer +
35 "&version=" + version +"&period=" + str(conf.PERIOD))
36 request = Request(url)
39 response = urlopen(request)
42 results = json.loads(k)
43 test_results = results['results']
45 print 'Got an error code:', e
48 if test_results is not None:
49 for r in test_results:
50 if r['stop_date'] != 'None':
51 if not r['scenario'] in scenario_results.keys():
52 scenario_results[r['scenario']] = []
53 scenario_results[r['scenario']].append(r)
55 for k,v in scenario_results.items():
56 scenario_results[k] = v[:conf.LASTEST_TESTS]
58 return scenario_results
62 status = getScenarioStatus("compass", "master")
63 print "status:++++++++++++++++++++++++"
64 print json.dumps(status,indent=4)
67 if __name__ == '__main__': # pragma: no cover