Mercurial > mozilla > hg > talosnames
changeset 42:cc0edf61ab21
require all the things!
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 12 Aug 2012 23:10:16 -0700 |
parents | 4dfa9c298e3d |
children | 4e8c839dcdec |
files | talosnames/api.py talosnames/require.py |
diffstat | 2 files changed, 35 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/talosnames/api.py Sun Aug 12 22:38:12 2012 -0700 +++ b/talosnames/api.py Sun Aug 12 23:10:16 2012 -0700 @@ -20,10 +20,15 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) class TalosNames(object): + + # files for graphserver graphserver_sql = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/data.sql' schema = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/schema.sql' + + # files for buildbot project_branches = 'http://hg.mozilla.org/build/buildbot-configs/raw-file/tip/mozilla/project_branches.py' buildbot_config = 'http://hg.mozilla.org/build/buildbot-configs/raw-file/tip/mozilla-tests/config.py' + localconfig = 'http://hg.mozilla.org/build/buildbot-configs/raw-file/tip/mozilla-tests/production_config.py' # mapping file from builbot-configs name to tbpl codes: # http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/file/tip/js/Config.js @@ -88,8 +93,10 @@ self.tbpl_regexs[name] = _regex def setup_buildbot(self): -# project_branches = require.require(self.project_branches) - module = require.require(self.buildbot_config) + localconfig, project_branches, module = require.require(self.localconfig, + self.project_branches, + self.buildbot_config, + **{self.localconfig: "localconfig.py"}) self.suites = module.SUITES self.buildbot_commands = {} self.buildbot_enabled = {}
--- a/talosnames/require.py Sun Aug 12 22:38:12 2012 -0700 +++ b/talosnames/require.py Sun Aug 12 23:10:16 2012 -0700 @@ -1,20 +1,37 @@ import imp import os +import sys import tempfile import urllib2 -def require(url): +def require(*urls, **filenames): """ import a module from the web url should be like scheme://host.name/path/to/module.py """ - contents = urllib2.urlopen(url).read() - filename = url.rsplit('/', 1)[-1] - module = filename.rsplit('.', 1)[-1] - dest = tempfile.mktemp(suffix='.py', prefix=module) - f = file(dest, 'w') - f.write(contents) - f.close() - return imp.load_source(module, dest) + + tempdir = tempfile.mkdtemp() + sys.path.insert(0, tempdir) + retval = [] + + for url in urls: + contents = urllib2.urlopen(url).read() + filename = filenames.get(url, None) + if not filename: + filename = url.rsplit('/', 1)[-1] + module = filename.rsplit('.', 1)[0] + dest = os.path.join(tempdir, filename) + f = file(dest, 'w') + f.write(contents) + f.close() + try: + _module = imp.load_source(module, dest) + except Exception, e: + raise +# import pdb; pdb.set_trace() + retval.append(_module) + + sys.path.pop(0) + return retval # TODO: make an equivalent method for a tarball