Mercurial > treepkg
comparison bin/runtreepkg.py @ 290:97c17fb0ca19
Add --track-option command line option to set track-specific options.
useful to e.g. specify a specific tag to package.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Fri, 18 Sep 2009 13:45:41 +0000 |
parents | 1fcdffbeb9de |
children | 5f442b0cf3a4 |
comparison
equal
deleted
inserted
replaced
289:433a49cacefc | 290:97c17fb0ca19 |
---|---|
25 hdlr = logging.StreamHandler() | 25 hdlr = logging.StreamHandler() |
26 fmt = logging.Formatter("%(asctime)s %(levelname)s %(message)s") | 26 fmt = logging.Formatter("%(asctime)s %(levelname)s %(message)s") |
27 hdlr.setFormatter(fmt) | 27 hdlr.setFormatter(fmt) |
28 root.addHandler(hdlr) | 28 root.addHandler(hdlr) |
29 | 29 |
30 def handle_track_option(option, opt_str, value, parser): | |
31 parsed_options = parser.values.track_options | |
32 track_optname, value = value.split("=", 1) | |
33 trackname, optname = track_optname.split(".") | |
34 track_options = parsed_options.setdefault(trackname, dict()) | |
35 track_options[optname] = value | |
36 | |
30 def parse_commandline(): | 37 def parse_commandline(): |
31 parser = create_parser() | 38 parser = create_parser() |
39 parser.set_defaults(track_options=dict()) | |
32 parser.add_option("--once", action="store_true", | 40 parser.add_option("--once", action="store_true", |
33 help=("Check the packagers only once and exit afterwards." | 41 help=("Check the packagers only once and exit afterwards." |
34 " Without this option, the tree packager will" | 42 " Without this option, the tree packager will" |
35 " check periodically.")) | 43 " check periodically.")) |
36 parser.add_option("--revision", | 44 parser.add_option("--revision", |
37 help=("SVN revision to update to before attempting" | 45 help=("SVN revision to update to before attempting" |
38 " to package.")) | 46 " to package.")) |
39 parser.add_option("--no-svn-update", action="store_true", | 47 parser.add_option("--no-svn-update", action="store_true", |
40 help=("Do not update the SVN workingcopy before" | 48 help=("Do not update the SVN workingcopy before" |
41 " attempting to package.")) | 49 " attempting to package.")) |
50 parser.add_option("--track-option", action="callback", type="string", | |
51 callback=handle_track_option, | |
52 help=("Sets a track-specific option." | |
53 " The argument should be of the form" | |
54 " TRACKNAME.OPTION=VALUE")) | |
42 return parser.parse_args() | 55 return parser.parse_args() |
43 | 56 |
44 def main(): | 57 def main(): |
45 options, args = parse_commandline() | 58 options, args = parse_commandline() |
46 | 59 |
55 | 68 |
56 for opts in packager_opts: | 69 for opts in packager_opts: |
57 name = opts["name"] | 70 name = opts["name"] |
58 opts["do_build"] = name in selected_tracks | 71 opts["do_build"] = name in selected_tracks |
59 selected_tracks.discard(name) | 72 selected_tracks.discard(name) |
73 if name in options.track_options: | |
74 opts.update(options.track_options[name]) | |
60 for name in selected_tracks: | 75 for name in selected_tracks: |
61 print >>sys.stderr, "No package track found named %r" % name | 76 print >>sys.stderr, "No package track found named %r" % name |
62 | 77 |
63 if packager_opts: | 78 if packager_opts: |
64 group = PackagerGroup([create_package_track(**opts) | 79 group = PackagerGroup([create_package_track(**opts) |