comparison 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
comparison
equal deleted inserted replaced
9:ab2bd5dda72c 10:1029ddf7b806
1 def require(url):
2 """
3 import a module from the web
4 url should be like scheme://host.name/path/to/module.py
5 """
6 import imp
7 import os
8 import tempfile
9 import urllib2
10 contents = urllib2.urlopen(url).read()
11 filename = url.rsplit('/', 1)[-1]
12 module = filename.rsplit('.', 1)[-1]
13 dest = tempfile.mktemp(suffix='.py', prefix=module)
14 f = file(dest, 'w')
15 f.write(contents)
16 f.close()
17 return imp.load_source(module, dest)
18
19 # TODO: make an equivalent method for a tarball