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 |
|
15 from treepkg.packager import AssemblyLine, Packager |
|
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")) |
|
31 parser.add_option("--config-file") |
|
32 return parser.parse_args() |
|
33 |
|
34 def main(): |
|
35 options, args = parse_commandline() |
|
36 |
|
37 initialize_logging() |
|
38 |
|
39 treepkg_opts, assembly_line_opts = read_config(options.config_file) |
|
40 packager = Packager([AssemblyLine(**opts) for opts in assembly_line_opts], |
|
41 **treepkg_opts) |
|
42 packager.run() |
|
43 |
|
44 main() |