def create(buildout_directory, buildout_extends): """Create buildout directory """ ## # Resolve arguments directory = get_buildout_directory(buildout_directory) extends = get_buildout_extends(buildout_extends) ## # Create buildout directory local('mkdir -p {0:s}'.format(directory)) ## # Create buildout.cfg filename = os.path.join(directory, 'buildout.cfg') contents = """\ [buildout] extends = {0:s} """.format(extends) ## # Write buildout.cfg with NamedTemporaryFile() as output: print("[localhost] create: {0:s}".format(output.name)) output.write(contents) output.flush() local('cp {0:s} {1:s}'.format(output.name, filename)) local('chmod a+r {0:s}'.format(filename))
def run(self, *args, **kwargs): buildout_directory = get_buildout_directory(api.env.host) buildout = get_buildout_config( os.path.join(buildout_directory, 'buildout.cfg') ) keys = api.env.keys() config = dict([ (key.replace('-', '_'), value) for key, value in buildout.get('aja', {}).items() if key in keys ]) if 'host_string' in config: config.update(parse_host_string(config.get('host_string'))) config['buildout'] = buildout directory = buildout.get('buildout', {}).get('directory') with settings(**config): with lcd(directory): return self.func(*args, **kwargs)