comparison talosnames/api.py @ 10:1029ddf7b806

get the buildbot config
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 10 Jul 2012 16:22:58 -0700
parents 82aad57c7d1d
children a4aa9f83e3be
comparison
equal deleted inserted replaced
9:ab2bd5dda72c 10:1029ddf7b806
1 import re 1 import re
2 import require
2 import sqlite3 3 import sqlite3
3 import urllib2 4 import urllib2
4 5
5 class TalosNames(object): 6 class TalosNames(object):
6 graphserver_sql = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/data.sql' 7 graphserver_sql = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/data.sql'
7 schema = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/schema.sql' 8 schema = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/schema.sql'
9 project_branches = 'http://hg.mozilla.org/build/buildbot-configs/raw-file/tip/mozilla/project_branches.py'
10 buildbot_config = 'http://hg.mozilla.org/build/buildbot-configs/raw-file/tip/mozilla-tests/config.py'
8 11
9 # mapping file from builbot-configs name to tbpl codes: 12 # mapping file from builbot-configs name to tbpl codes:
10 # http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/file/tip/js/Config.js 13 # http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/file/tip/js/Config.js
11 tbpl_map = 'http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/raw-file/tip/js/Data.js' 14 tbpl_map = 'http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/raw-file/tip/js/Data.js'
12 15
15 'machines': '(id, os_id int, is_throttling int, cpu_speed text, name text, is_active int, date_added int)', 18 'machines': '(id, os_id int, is_throttling int, cpu_speed text, name text, is_active int, date_added int)',
16 'pagesets': '(id, name text)', 19 'pagesets': '(id, name text)',
17 'tests': '(id, name text, pretty_name text, is_chrome int, is_active int, pageset_id int)' 20 'tests': '(id, name text, pretty_name text, is_chrome int, is_active int, pageset_id int)'
18 } 21 }
19 22
23 ### initialization functions
24
20 def __init__(self): 25 def __init__(self):
21 self.setup_database() 26 self.setup_database()
22 self.tbpl_mapping() 27 self.tbpl_mapping()
28 self.setup_buildbot()
23 29
24 def setup_database(self): 30 def setup_database(self):
25 self.db = sqlite3.connect(':memory:') 31 self.db = sqlite3.connect(':memory:')
26 sql_lines = urllib2.urlopen(self.graphserver_sql).readlines() 32 sql_lines = urllib2.urlopen(self.graphserver_sql).readlines()
27 33
59 match = regex.match(line) 65 match = regex.match(line)
60 assert match 66 assert match
61 _regex, name = match.groups() 67 _regex, name = match.groups()
62 self.tbpl_regexs[name] = _regex 68 self.tbpl_regexs[name] = _regex
63 69
70 def setup_buildbot(self):
71 # project_branches = require.require(self.project_branches)
72 module = require.require(self.buildbot_config)
73 self.suites = module.SUITES
74
75 ### functions for fetching information
76
77 def tbpl_name(self, name):
78 """returns the TBPL long name"""
79 for tbplname, regex in self.tbpl_regexs.items():
80 regex = re.compile(regex)
81 if regex.match(name):
82 return tbplname
83
64 def __call__(self, name=None): 84 def __call__(self, name=None):
65 retval = [] 85 retval = []
66 for short_name, graphserver_name in self.names.items(): 86 for short_name, graphserver_name in self.names.items():
67 if (name is None) or (name == short_name or short_name.startswith(name + '_')): 87 if (name is None) or (name == short_name or short_name.startswith(name + '_')):
68 retval.append((short_name, graphserver_name)) 88 retval.append((short_name, graphserver_name))