blob: ae81de309e9e80f5f447ecc634dfa53f67a0cd7c [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
5"""Run an autoserv control file
6
7TODO(poirier): add a singleton logger
8TODO(poirier): maybe change the name "get_file" to "receive_file" ?
9"""
10
11__author__ = "poirier@google.com (Benjamin Poirier)"
12
13
14import sys
15import optparse
16
17
18usage = "usage: %prog <control file>"
19parser = optparse.OptionParser(usage)
20
21
22def parse_args():
23 global parser
24
25 (options, arg)= parser.parse_args()
26 return (options, arg)
27
28
29def run(control_file):
30 namespace = {}
31
32 str = ("import os\n"
33 "import sys\n"
34 "\n"
35 "import errors\n"
36 "import hosts\n"
37 "import autotest\n"
38 "import source_kernel\n"
39 "import rpm_kernel\n"
40 "import deb_kernel\n"
41 "import kvm\n"
42 "\n"
43 "from utils import run, get_tmp_dir\n")
44 exec(str, namespace, namespace)
45 execfile(sys.argv[1], namespace, namespace)
46
47
48if __name__ == "__main__":
49 (options, args) = parse_args()
50 if len(args) != 1:
51 parser.error("program takes one argument")
52 sys.exit(1)
53 control_file= args[0]
54 run(control_file)