comparison talosnames/api.py @ 12:a4aa9f83e3be

adding a thing for commands
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 10 Jul 2012 17:01:05 -0700
parents 1029ddf7b806
children 323a01abd180
comparison
equal deleted inserted replaced
11:b7b59561be5e 12:a4aa9f83e3be
1 import os
1 import re 2 import re
2 import require 3 import require
3 import sqlite3 4 import sqlite3
5 import sys
4 import urllib2 6 import urllib2
7
8 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
5 9
6 class TalosNames(object): 10 class TalosNames(object):
7 graphserver_sql = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/data.sql' 11 graphserver_sql = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/data.sql'
8 schema = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/schema.sql' 12 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' 13 project_branches = 'http://hg.mozilla.org/build/buildbot-configs/raw-file/tip/mozilla/project_branches.py'
69 73
70 def setup_buildbot(self): 74 def setup_buildbot(self):
71 # project_branches = require.require(self.project_branches) 75 # project_branches = require.require(self.project_branches)
72 module = require.require(self.buildbot_config) 76 module = require.require(self.buildbot_config)
73 self.suites = module.SUITES 77 self.suites = module.SUITES
78 self.buildbot_commands = {}
79 for key, value in self.suites.items():
80 self.buildbot_commands[key] = value['suites']
74 81
75 ### functions for fetching information 82 ### functions for fetching information
76 83
77 def tbpl_name(self, name): 84 def tbpl_name(self, name):
78 """returns the TBPL long name""" 85 """returns the TBPL long name"""
79 for tbplname, regex in self.tbpl_regexs.items(): 86 for tbplname, regex in self.tbpl_regexs.items():
80 regex = re.compile(regex) 87 regex = re.compile(regex)
81 if regex.match(name): 88 if regex.match(name):
82 return tbplname 89 return tbplname
83 90
91 def buildbot_command(self, name):
92 """gets the buildbot command for a particular suite"""
93 return self.buildbot_commands.get(name)
94
84 def __call__(self, name=None): 95 def __call__(self, name=None):
85 retval = [] 96 retval = []
86 for short_name, graphserver_name in self.names.items(): 97 for short_name, graphserver_name in self.names.items():
87 if (name is None) or (name == short_name or short_name.startswith(name + '_')): 98 if (name is None) or (name == short_name or short_name.startswith(name + '_')):
88 retval.append((short_name, graphserver_name)) 99 retval.append((short_name, graphserver_name))