Mercurial > treepkg
comparison bin/runtreepkg.py @ 78:9a602d8eaa60
initial revision of the subversion repository
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 24 Apr 2012 17:13:43 +0200 |
parents | |
children | 2630a1c18816 |
comparison
equal
deleted
inserted
replaced
77:f0aa5a8af056 | 78:9a602d8eaa60 |
---|---|
1 #! /usr/bin/python2.4 | |
2 # Copyright (C) 2007 by Intevation GmbH | |
3 # Authors: | |
4 # Bernhard Herzog <bh@intevation.de> | |
5 # | |
6 # This program is free software under the GPL (>=v2) | |
7 # Read the file COPYING coming with the software for details. | |
8 | |
9 """Starts the tree packager""" | |
10 | |
11 import sys | |
12 import os | |
13 import logging | |
14 from optparse import OptionParser | |
15 | |
16 import treepkgcmd | |
17 from treepkg.options import create_parser | |
18 from treepkg.packager import create_package_track, PackagerGroup | |
19 from treepkg.readconfig import read_config | |
20 | |
21 def initialize_logging(): | |
22 """Initializes the logging system""" | |
23 root = logging.getLogger() | |
24 root.setLevel(logging.DEBUG) | |
25 hdlr = logging.StreamHandler() | |
26 fmt = logging.Formatter("%(asctime)s %(levelname)s %(message)s") | |
27 hdlr.setFormatter(fmt) | |
28 root.addHandler(hdlr) | |
29 | |
30 def parse_commandline(): | |
31 parser = create_parser() | |
32 parser.add_option("--once", action="store_true", | |
33 help=("Check the packagers only once and exit afterwards." | |
34 " Without this option, the tree packager will" | |
35 " check periodically.")) | |
36 return parser.parse_args() | |
37 | |
38 def main(): | |
39 options, args = parse_commandline() | |
40 | |
41 initialize_logging() | |
42 | |
43 treepkg_opts, packager_opts = read_config(options.config_file) | |
44 | |
45 if args: | |
46 packager_opts = [opts for opts in packager_opts if opts["name"] in args] | |
47 # check whether we got all of the names in args: | |
48 for opts in packager_opts: | |
49 name = opts["name"] | |
50 if name in args: | |
51 args.remove(name) | |
52 for name in args: | |
53 print >>sys.stderr, "No package tracks found named %r" % name | |
54 | |
55 if packager_opts: | |
56 group = PackagerGroup([create_package_track(**opts) | |
57 for opts in packager_opts], | |
58 **treepkg_opts) | |
59 if options.once: | |
60 group.check_package_tracks() | |
61 else: | |
62 group.run() | |
63 | |
64 main() |