Mercurial > mozilla > hg > talosnames
comparison talosnames/api.py @ 21:48b4c926be73
getting there
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 10 Jul 2012 18:56:34 -0700 |
parents | 25e91fc7ff01 |
children | 82d15f93cc4a |
comparison
equal
deleted
inserted
replaced
20:0a829ad6e116 | 21:48b4c926be73 |
---|---|
39 | 39 |
40 def __init__(self): | 40 def __init__(self): |
41 self.setup_database() | 41 self.setup_database() |
42 self.tbpl_mapping() | 42 self.tbpl_mapping() |
43 self.setup_buildbot() | 43 self.setup_buildbot() |
44 | |
45 # cache | |
44 self._talos_configs = {} | 46 self._talos_configs = {} |
47 self._tbpl_names = {} | |
45 | 48 |
46 def setup_database(self): | 49 def setup_database(self): |
47 self.db = sqlite3.connect(':memory:') | 50 self.db = sqlite3.connect(':memory:') |
48 sql_lines = urllib2.urlopen(self.graphserver_sql).readlines() | 51 sql_lines = urllib2.urlopen(self.graphserver_sql).readlines() |
49 | 52 |
93 | 96 |
94 ### functions for fetching information | 97 ### functions for fetching information |
95 | 98 |
96 def tbpl_name(self, name): | 99 def tbpl_name(self, name): |
97 """returns the TBPL long name""" | 100 """returns the TBPL long name""" |
101 if name in self._tbpl_names: | |
102 return self._tbpl_names[name] | |
98 for tbplname, regex in self.tbpl_regexs.items(): | 103 for tbplname, regex in self.tbpl_regexs.items(): |
99 regex = re.compile(regex) | 104 regex = re.compile(regex) |
100 if regex.match(name): | 105 if regex.match(name): |
106 self._tbpl_names[name] = tbplname | |
101 return tbplname | 107 return tbplname |
102 | 108 |
103 def buildbot_command(self, name): | 109 def buildbot_command(self, name): |
104 """gets the buildbot command for a particular suite""" | 110 """gets the buildbot command for a particular suite""" |
105 return self.buildbot_commands.get(name) | 111 return self.buildbot_commands.get(name) |
106 | 112 |
107 def talos_config(self, name): | 113 def talos_config(self, name): |
108 """returns talos configuration for suite `name`""" | 114 """returns talos configuration for suite `name`""" |
115 if name in self._talos_configs: | |
116 return self._talos_configs[name] | |
117 | |
109 command = self.buildbot_command(name) | 118 command = self.buildbot_command(name) |
110 assert command is not None, "Suite not found: %s" % name | 119 assert command is not None, "Suite not found: %s" % name |
111 outfile = tempfile.mktemp(suffix='.yml') | 120 outfile = tempfile.mktemp(suffix='.yml') |
112 command += ['-o', outfile] # add an output file | 121 command += ['-o', outfile] # add an output file |
113 command += ['-e', sys.executable] # add a pretend firefox so PerfConfigurator won't whine | 122 command += ['-e', sys.executable] # add a pretend firefox so PerfConfigurator won't whine |
114 call(['PerfConfigurator'] + command, stdout=subprocess.PIPE, cwd=talos_dir) | 123 call(['PerfConfigurator'] + command, stdout=subprocess.PIPE, cwd=talos_dir) |
115 assert os.path.exists(outfile) | 124 assert os.path.exists(outfile) |
116 config = yaml.load(file(outfile)) | 125 config = yaml.load(file(outfile)) |
126 self._talos_configs[name] = config | |
117 return config | 127 return config |
118 | 128 |
119 def test_config(self, name): | 129 def test_config(self, name): |
120 test_config = self.talos_config(name)['tests'] | 130 test_config = self.talos_config(name)['tests'] |
121 retval = {} | 131 retval = {} |