Mercurial > treepkg
annotate runtreepkg.py @ 50:225206553bba
update README part about pbuilder config
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Tue, 03 Apr 2007 11:24:48 +0200 |
parents | 206d63ee310e |
children | 78cf5f6778ec |
rev | line source |
---|---|
0 | 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 | |
27
206d63ee310e
cope with unknown packager names in runtreepkg.py
Bernhard Herzog <bh@intevation.de>
parents:
25
diff
changeset
|
11 import sys |
0 | 12 import os |
13 import logging | |
14 from optparse import OptionParser | |
15 | |
8
574506a022f6
Rename AssemblyLine to PackageLine
Bernhard Herzog <bh@intevation.de>
parents:
7
diff
changeset
|
16 from treepkg.packager import create_package_line, PackagerGroup |
0 | 17 from treepkg.readconfig import read_config |
18 | |
19 def initialize_logging(): | |
20 """Initializes the logging system""" | |
21 root = logging.getLogger() | |
22 root.setLevel(logging.DEBUG) | |
23 hdlr = logging.StreamHandler() | |
24 fmt = logging.Formatter("%(asctime)s %(levelname)s %(message)s") | |
25 hdlr.setFormatter(fmt) | |
26 root.addHandler(hdlr) | |
27 | |
28 def parse_commandline(): | |
29 parser = OptionParser() | |
30 parser.set_defaults(config_file=os.path.join(os.path.dirname(__file__), | |
31 "treepkg.cfg")) | |
25
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
32 parser.add_option("--config-file", |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
33 help=("The tree packager config file." |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
34 " Default treepkg.cfg")) |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
35 parser.add_option("--once", action="store_true", |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
36 help=("Check the packagers only once and exit afterwards." |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
37 " Without this option, the tree packager will" |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
38 " check periodically.")) |
0 | 39 return parser.parse_args() |
40 | |
41 def main(): | |
42 options, args = parse_commandline() | |
43 | |
44 initialize_logging() | |
45 | |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
46 treepkg_opts, packager_opts = read_config(options.config_file) |
27
206d63ee310e
cope with unknown packager names in runtreepkg.py
Bernhard Herzog <bh@intevation.de>
parents:
25
diff
changeset
|
47 |
25
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
48 if args: |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
49 packager_opts = [opts for opts in packager_opts if opts["name"] in args] |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
50 # check whether we got all of the names in args: |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
51 for opts in packager_opts: |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
52 name = opts["name"] |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
53 if name in args: |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
54 args.remove(name) |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
55 for name in args: |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
56 print >>sys.stderr, "No package lines found named %r" % name |
27
206d63ee310e
cope with unknown packager names in runtreepkg.py
Bernhard Herzog <bh@intevation.de>
parents:
25
diff
changeset
|
57 |
206d63ee310e
cope with unknown packager names in runtreepkg.py
Bernhard Herzog <bh@intevation.de>
parents:
25
diff
changeset
|
58 if packager_opts: |
206d63ee310e
cope with unknown packager names in runtreepkg.py
Bernhard Herzog <bh@intevation.de>
parents:
25
diff
changeset
|
59 group = PackagerGroup([create_package_line(**opts) |
206d63ee310e
cope with unknown packager names in runtreepkg.py
Bernhard Herzog <bh@intevation.de>
parents:
25
diff
changeset
|
60 for opts in packager_opts], |
206d63ee310e
cope with unknown packager names in runtreepkg.py
Bernhard Herzog <bh@intevation.de>
parents:
25
diff
changeset
|
61 **treepkg_opts) |
206d63ee310e
cope with unknown packager names in runtreepkg.py
Bernhard Herzog <bh@intevation.de>
parents:
25
diff
changeset
|
62 if options.once: |
206d63ee310e
cope with unknown packager names in runtreepkg.py
Bernhard Herzog <bh@intevation.de>
parents:
25
diff
changeset
|
63 group.check_package_lines() |
206d63ee310e
cope with unknown packager names in runtreepkg.py
Bernhard Herzog <bh@intevation.de>
parents:
25
diff
changeset
|
64 else: |
206d63ee310e
cope with unknown packager names in runtreepkg.py
Bernhard Herzog <bh@intevation.de>
parents:
25
diff
changeset
|
65 group.run() |
0 | 66 |
67 main() |