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
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
1 #! /usr/bin/python2.4
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
2 # Copyright (C) 2007 by Intevation GmbH
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
3 # Authors:
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
4 # Bernhard Herzog <bh@intevation.de>
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
5 #
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
6 # This program is free software under the GPL (>=v2)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
7 # Read the file COPYING coming with the software for details.
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
8
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
9 """Starts the tree packager"""
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
10
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
11 import os
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
12 import logging
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
13 from optparse import OptionParser
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
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
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
16 from treepkg.readconfig import read_config
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
17
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
18 def initialize_logging():
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
19 """Initializes the logging system"""
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
20 root = logging.getLogger()
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
21 root.setLevel(logging.DEBUG)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
22 hdlr = logging.StreamHandler()
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
23 fmt = logging.Formatter("%(asctime)s %(levelname)s %(message)s")
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
24 hdlr.setFormatter(fmt)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
25 root.addHandler(hdlr)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
26
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
27 def parse_commandline():
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
28 parser = OptionParser()
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
29 parser.set_defaults(config_file=os.path.join(os.path.dirname(__file__),
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
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
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
38 return parser.parse_args()
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
39
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
40 def main():
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
41 options, args = parse_commandline()
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
42
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
43 initialize_logging()
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
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
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
62
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
63 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)