mbligh | dcd57a8 | 2007-07-11 23:06:47 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # |
| 3 | # Copyright 2007 Google Inc. Released under the GPL v2 |
| 4 | |
mbligh | c8949b8 | 2007-07-23 16:33:58 +0000 | [diff] [blame^] | 5 | """ |
| 6 | Run an autoserv control file |
mbligh | dcd57a8 | 2007-07-11 23:06:47 +0000 | [diff] [blame] | 7 | |
| 8 | TODO(poirier): add a singleton logger |
| 9 | TODO(poirier): maybe change the name "get_file" to "receive_file" ? |
mbligh | c8949b8 | 2007-07-23 16:33:58 +0000 | [diff] [blame^] | 10 | TODO(poirier): change get(), send_file(), get_file() to consistantly recognize |
| 11 | paths that start with '~' as refering to the home directory |
mbligh | dcd57a8 | 2007-07-11 23:06:47 +0000 | [diff] [blame] | 12 | """ |
| 13 | |
mbligh | c8949b8 | 2007-07-23 16:33:58 +0000 | [diff] [blame^] | 14 | __author__ = """ |
| 15 | mbligh@google.com (Martin J. Bligh), |
| 16 | poirier@google.com (Benjamin Poirier), |
| 17 | stutsman@google.com (Ryan Stutsman) |
| 18 | """ |
mbligh | dcd57a8 | 2007-07-11 23:06:47 +0000 | [diff] [blame] | 19 | |
| 20 | |
| 21 | import sys |
| 22 | import optparse |
| 23 | |
| 24 | |
| 25 | usage = "usage: %prog <control file>" |
| 26 | parser = optparse.OptionParser(usage) |
| 27 | |
| 28 | |
| 29 | def parse_args(): |
| 30 | global parser |
| 31 | |
| 32 | (options, arg)= parser.parse_args() |
| 33 | return (options, arg) |
| 34 | |
| 35 | |
| 36 | def 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 | |
| 55 | if __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) |