bh@287: #! /usr/bin/python bh@287: # Copyright (C) 2007, 2008, 2009 by Intevation GmbH thomas@78: # Authors: thomas@78: # Bernhard Herzog thomas@78: # thomas@78: # This program is free software under the GPL (>=v2) thomas@78: # Read the file COPYING coming with the software for details. thomas@78: thomas@78: """Starts the tree packager""" thomas@78: thomas@78: import sys thomas@78: import os thomas@78: import logging thomas@78: from optparse import OptionParser thomas@78: thomas@78: import treepkgcmd thomas@78: from treepkg.options import create_parser thomas@78: from treepkg.packager import create_package_track, PackagerGroup thomas@78: from treepkg.readconfig import read_config thomas@78: thomas@78: def initialize_logging(): thomas@78: """Initializes the logging system""" thomas@78: root = logging.getLogger() thomas@78: root.setLevel(logging.DEBUG) thomas@78: hdlr = logging.StreamHandler() thomas@78: fmt = logging.Formatter("%(asctime)s %(levelname)s %(message)s") thomas@78: hdlr.setFormatter(fmt) thomas@78: root.addHandler(hdlr) thomas@78: thomas@78: def parse_commandline(): thomas@78: parser = create_parser() thomas@78: parser.add_option("--once", action="store_true", thomas@78: help=("Check the packagers only once and exit afterwards." thomas@78: " Without this option, the tree packager will" thomas@78: " check periodically.")) bh@81: parser.add_option("--revision", bh@81: help=("SVN revision to update to before attempting" bh@81: " to package.")) bh@190: parser.add_option("--no-svn-update", action="store_true", bh@190: help=("Do not update the SVN workingcopy before" bh@190: " attempting to package.")) thomas@78: return parser.parse_args() thomas@78: thomas@78: def main(): thomas@78: options, args = parse_commandline() thomas@78: thomas@78: initialize_logging() thomas@78: thomas@78: treepkg_opts, packager_opts = read_config(options.config_file) thomas@78: thomas@78: if args: bh@191: selected_tracks = set(args) bh@191: else: bh@191: selected_tracks = set(opts["name"] for opts in packager_opts) bh@191: bh@191: for opts in packager_opts: bh@191: name = opts["name"] bh@191: opts["do_build"] = name in selected_tracks bh@191: selected_tracks.discard(name) bh@191: for name in selected_tracks: bh@191: print >>sys.stderr, "No package track found named %r" % name thomas@78: thomas@78: if packager_opts: thomas@78: group = PackagerGroup([create_package_track(**opts) thomas@78: for opts in packager_opts], bh@81: revision=options.revision, bh@190: do_svn_update=not options.no_svn_update, thomas@78: **treepkg_opts) thomas@78: if options.once: thomas@78: group.check_package_tracks() thomas@78: else: thomas@78: group.run() thomas@78: thomas@78: main()