changeset 21:48b4c926be73

getting there
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 10 Jul 2012 18:56:34 -0700
parents 0a829ad6e116
children 82d15f93cc4a
files talosnames/api.py talosnames/templates/index.html talosnames/web.py
diffstat 3 files changed, 36 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/talosnames/api.py	Tue Jul 10 18:39:46 2012 -0700
+++ b/talosnames/api.py	Tue Jul 10 18:56:34 2012 -0700
@@ -41,7 +41,10 @@
         self.setup_database()
         self.tbpl_mapping()
         self.setup_buildbot()
+
+        # cache
         self._talos_configs = {}
+        self._tbpl_names = {}
 
     def setup_database(self):
         self.db = sqlite3.connect(':memory:')
@@ -95,9 +98,12 @@
 
     def tbpl_name(self, name):
         """returns the TBPL long name"""
+        if name in self._tbpl_names:
+            return self._tbpl_names[name]
         for tbplname, regex in self.tbpl_regexs.items():
             regex = re.compile(regex)
             if regex.match(name):
+                self._tbpl_names[name] = tbplname
                 return tbplname
 
     def buildbot_command(self, name):
@@ -106,6 +112,9 @@
 
     def talos_config(self, name):
         """returns talos configuration for suite `name`"""
+        if name in self._talos_configs:
+            return self._talos_configs[name]
+
         command = self.buildbot_command(name)
         assert command is not None, "Suite not found: %s" % name
         outfile = tempfile.mktemp(suffix='.yml')
@@ -114,6 +123,7 @@
         call(['PerfConfigurator'] + command, stdout=subprocess.PIPE, cwd=talos_dir)
         assert os.path.exists(outfile)
         config = yaml.load(file(outfile))
+        self._talos_configs[name] = config
         return config
 
     def test_config(self, name):
--- a/talosnames/templates/index.html	Tue Jul 10 18:39:46 2012 -0700
+++ b/talosnames/templates/index.html	Tue Jul 10 18:56:34 2012 -0700
@@ -15,6 +15,17 @@
   <th>TBPL Name</th>
   <th>Talos Tests</th>
 </tr>
+{{for suite in suites}}
+<tr>
+  <td>{{suite}}</td>
+  <td><tt>{{repr(commands[suite])}}</tt></td>
+  <td>{{tbpl[suite]}}</td>
+  <td><pre>foo
+
+
+bar</pre></td>
+</tr>
+{{endfor}}
 </table>
 </body>
 </html>
--- a/talosnames/web.py	Tue Jul 10 18:39:46 2012 -0700
+++ b/talosnames/web.py	Tue Jul 10 18:56:34 2012 -0700
@@ -26,7 +26,21 @@
 
     def render(self):
         template = tempita.HTMLTemplate(self.template)
-        data = {}
+        suites = sorted(self.api.suites.keys())
+        tests = {}
+        for suite in suites:
+            try:
+                test = self.api.test_config(suite)
+                tests[suite] = test
+            except:
+                tests[suite] = None
+
+        data = {'suites': suites,
+                'commands': self.api.buildbot_commands,
+                'tbpl': dict([(suite, self.api.tbpl_name(suite))
+                              for suite in suites]),
+                'tests': tests
+                }
         return template.substitute(data)
 
 if __name__ == '__main__':