blob: 8ff6f9245b4a50f86fd81f49b85ad7e8db2758ae [file] [log] [blame]
mblighdcd57a82007-07-11 23:06:47 +00001#!/usr/bin/python
2#
3# Copyright 2007 Google Inc. Released under the GPL v2
4
mblighc8949b82007-07-23 16:33:58 +00005"""
6Run an autoserv control file
mblighdcd57a82007-07-11 23:06:47 +00007
8TODO(poirier): add a singleton logger
9TODO(poirier): maybe change the name "get_file" to "receive_file" ?
mblighc8949b82007-07-23 16:33:58 +000010TODO(poirier): change get(), send_file(), get_file() to consistantly recognize
11 paths that start with '~' as refering to the home directory
mblighdcd57a82007-07-11 23:06:47 +000012"""
13
mblighc8949b82007-07-23 16:33:58 +000014__author__ = """
15mbligh@google.com (Martin J. Bligh),
16poirier@google.com (Benjamin Poirier),
17stutsman@google.com (Ryan Stutsman)
18"""
mblighdcd57a82007-07-11 23:06:47 +000019
20
21import sys
22import optparse
23
24
25usage = "usage: %prog <control file>"
26parser = optparse.OptionParser(usage)
27
28
29def parse_args():
30 global parser
31
32 (options, arg)= parser.parse_args()
33 return (options, arg)
34
35
36def run(control_file):
37 namespace = {}
38
39 str = ("import os\n"
40 "import sys\n"
41 "\n"
42 "import errors\n"
43 "import hosts\n"
44 "import autotest\n"
45 "import source_kernel\n"
46 "import rpm_kernel\n"
47 "import deb_kernel\n"
48 "import kvm\n"
49 "\n"
50 "from utils import run, get_tmp_dir\n")
51 exec(str, namespace, namespace)
52 execfile(sys.argv[1], namespace, namespace)
53
54
55if __name__ == "__main__":
56 (options, args) = parse_args()
57 if len(args) != 1:
58 parser.error("program takes one argument")
59 sys.exit(1)
60 control_file= args[0]
61 run(control_file)