Mercurial > treepkg
annotate runtreepkg.py @ 26:06fba656dde8
fix typo
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Wed, 14 Mar 2007 17:48:23 +0100 |
parents | 2bfb84bc4350 |
children | 206d63ee310e |
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 | |
11 import os | |
12 import logging | |
13 from optparse import OptionParser | |
14 | |
8
574506a022f6
Rename AssemblyLine to PackageLine
Bernhard Herzog <bh@intevation.de>
parents:
7
diff
changeset
|
15 from treepkg.packager import create_package_line, PackagerGroup |
0 | 16 from treepkg.readconfig import read_config |
17 | |
18 def initialize_logging(): | |
19 """Initializes the logging system""" | |
20 root = logging.getLogger() | |
21 root.setLevel(logging.DEBUG) | |
22 hdlr = logging.StreamHandler() | |
23 fmt = logging.Formatter("%(asctime)s %(levelname)s %(message)s") | |
24 hdlr.setFormatter(fmt) | |
25 root.addHandler(hdlr) | |
26 | |
27 def parse_commandline(): | |
28 parser = OptionParser() | |
29 parser.set_defaults(config_file=os.path.join(os.path.dirname(__file__), | |
30 "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
|
31 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
|
32 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
|
33 " 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
|
34 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
|
35 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
|
36 " 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
|
37 " check periodically.")) |
0 | 38 return parser.parse_args() |
39 | |
40 def main(): | |
41 options, args = parse_commandline() | |
42 | |
43 initialize_logging() | |
44 | |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
45 treepkg_opts, packager_opts = read_config(options.config_file) |
25
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
46 if args: |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
47 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
|
48 # 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 print >>sys.stderr, "No package lines found named %r" % name |
8
574506a022f6
Rename AssemblyLine to PackageLine
Bernhard Herzog <bh@intevation.de>
parents:
7
diff
changeset
|
55 group = PackagerGroup([create_package_line(**opts) |
574506a022f6
Rename AssemblyLine to PackageLine
Bernhard Herzog <bh@intevation.de>
parents:
7
diff
changeset
|
56 for opts in packager_opts], |
7
96f4f58c62b5
Rename the Packager class to PackagerGroup
Bernhard Herzog <bh@intevation.de>
parents:
4
diff
changeset
|
57 **treepkg_opts) |
25
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
58 if options.once: |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
59 group.check_package_lines() |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
60 else: |
2bfb84bc4350
runtreepkg.py: add option --once and a way to run specific packagers
Bernhard Herzog <bh@intevation.de>
parents:
8
diff
changeset
|
61 group.run() |
0 | 62 |
63 main() |