Mercurial > mozilla > hg > talosnames
diff talosnames/require.py @ 10:1029ddf7b806
get the buildbot config
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 10 Jul 2012 16:22:58 -0700 |
parents | |
children | 1b18b2746e69 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/talosnames/require.py Tue Jul 10 16:22:58 2012 -0700 @@ -0,0 +1,19 @@ +def require(url): + """ + import a module from the web + url should be like scheme://host.name/path/to/module.py + """ + import imp + import os + import tempfile + import urllib2 + 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) + +# TODO: make an equivalent method for a tarball