bh@0: #! /usr/bin/python2.4 bh@0: # Copyright (C) 2007 by Intevation GmbH bh@0: # Authors: bh@0: # Bernhard Herzog bh@0: # bh@0: # This program is free software under the GPL (>=v2) bh@0: # Read the file COPYING coming with the software for details. bh@0: bh@0: """Starts the tree packager""" bh@0: bh@0: import os bh@0: import logging bh@0: from optparse import OptionParser bh@0: bh@8: from treepkg.packager import create_package_line, PackagerGroup bh@0: from treepkg.readconfig import read_config bh@0: bh@0: def initialize_logging(): bh@0: """Initializes the logging system""" bh@0: root = logging.getLogger() bh@0: root.setLevel(logging.DEBUG) bh@0: hdlr = logging.StreamHandler() bh@0: fmt = logging.Formatter("%(asctime)s %(levelname)s %(message)s") bh@0: hdlr.setFormatter(fmt) bh@0: root.addHandler(hdlr) bh@0: bh@0: def parse_commandline(): bh@0: parser = OptionParser() bh@0: parser.set_defaults(config_file=os.path.join(os.path.dirname(__file__), bh@0: "treepkg.cfg")) bh@0: parser.add_option("--config-file") bh@0: return parser.parse_args() bh@0: bh@0: def main(): bh@0: options, args = parse_commandline() bh@0: bh@0: initialize_logging() bh@0: bh@4: treepkg_opts, packager_opts = read_config(options.config_file) bh@8: group = PackagerGroup([create_package_line(**opts) bh@8: for opts in packager_opts], bh@7: **treepkg_opts) bh@7: group.run() bh@0: bh@0: main()