autoserv revision 03dd07994874137a317bf0062daa60341084a9ee
1#!/usr/bin/python 2# 3# Copyright 2007 Google Inc. Released under the GPL v2 4 5""" 6Run an autoserv control file 7 8TODO(poirier): add a singleton logger 9TODO(poirier): maybe change the name "get_file" to "receive_file" ? 10TODO(poirier): change get(), send_file(), get_file() to consistantly recognize 11 paths that start with '~' as refering to the home directory 12""" 13 14__author__ = """ 15mbligh@google.com (Martin J. Bligh), 16poirier@google.com (Benjamin Poirier), 17stutsman@google.com (Ryan Stutsman) 18""" 19 20import sys 21import optparse 22 23 24def parse_args(): 25 usage = "usage: %prog <control file>" 26 parser = optparse.OptionParser(usage) 27 parser.add_option('-m', '--machines', dest='machines', type='string') 28 (options, arg) = parser.parse_args() 29 return (options, arg) 30 31 32preamble = """\ 33import os, sys 34 35import errors, hosts, autotest, kvm 36import source_kernel, rpm_kernel, deb_kernel 37from subcommand import * 38 39from utils import run, get_tmp_dir, sh_escape 40""" 41 42def run(control_file, machines): 43 namespace = dict({'machines': machines}) 44 45 exec(preamble, namespace, namespace) 46 execfile(control_file, namespace, namespace) 47 48 49if __name__ == "__main__": 50 (options, args) = parse_args() 51 if len(args) != 1: 52 parser.error("program takes one argument") 53 sys.exit(1) 54 control_file = args[0] 55 if options.machines: 56 run(control_file, options.machines.split(',')) 57 else: 58 run(control_file, None) 59