Fetching contributors…
Cannot retrieve contributors at this time
executable file 87 lines (67 sloc) 2.31 KB
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at
create a mozmill carton
import optparse
import os
import shutil
import sys
import tempfile
from subprocess import check_call as call
except ImportError:
from subprocess import call
### stuff that should be in the stdlib
def which(fileName, path=os.environ['PATH']):
"""python equivalent of which; should really be in the stdlib"""
dirs = path.split(os.pathsep)
for dir in dirs:
if os.path.isfile(os.path.join(dir, fileName)):
return os.path.join(dir, fileName)
def require(url):
import a module from the web
url should be like scheme://
import imp
import urllib2
contents = urllib2.urlopen(url).read()
filename = url.rsplit('/', 1)[-1]
modulename = filename.rsplit('.', 1)[-1]
fd, filename = tempfile.mkstemp(suffix='.py', prefix=modulename)
os.write(fd, contents)
module = imp.load_source(modulename, filename)
return module
### requirements
carton = require('')
git = which('git')
MOZBASE = 'git://'
MOZMILL = 'git://'
def main(args=sys.argv[1:]):
assert git, 'git executable not found!'
# parse command line options
parser = optparse.OptionParser()
parser.add_option('--name', dest='name', default='mozmill-env',
help='name of the environment')
options, args = parser.parse_args(args)
# checkout mozbase
tempdir = tempfile.mkdtemp()
mozbasedir = os.path.join(tempdir, 'mozbase')
call([git, 'clone', MOZBASE, mozbasedir])
# checkout mozmill
mozmilldir = os.path.join(tempdir, 'mozmill')
call([git, 'clone', MOZMILL, mozmilldir])
# make a carton
carton.main([, mozmilldir, mozbasedir,
'--python-script', 'src/mozbase/',
'--python-script', 'src/mozmill/',
# remove vestiges
if __name__ == '__main__':