source: soft/build_system/build_system/repsys/tags/V1_6_15/repsys @ 1

Last change on this file since 1 was 1, checked in by fasma, 12 years ago

Initial Import from Mandriva's soft revision 224062 and package revision 45733

File size: 1.3 KB
Line 
1#!/usr/bin/python
2from RepSys import Error
3from RepSys.command import *
4import getopt
5import sys
6
7VERSION="1.6.15"
8
9HELP = """\
10Usage: repsys COMMAND [COMMAND ARGUMENTS]
11
12Useful commands:
13    co
14    submit
15    create
16    getspec
17    getsrpm
18    rpmlog
19    changed
20    authoremail
21
22Run "repsys COMMAND --help" for more information.
23
24Written by Gustavo Niemeyer <gustavo@niemeyer.net>
25"""
26
27def parse_options():
28    parser = OptionParser(help=HELP, version="%prog "+VERSION)
29    parser.disable_interspersed_args()
30    parser.add_option("--debug", action="store_true")
31    opts, args = parser.parse_args()
32    if len(args) < 1:
33        parser.print_help(sys.stderr)
34        sys.exit(1)
35    opts.command = args[0]
36    opts.argv = args
37    return opts
38
39def dispatch_command(command, argv, debug=0):
40    sys.argv = argv
41    try:
42        repsys_module = __import__("RepSys.commands."+command)
43        commands_module = getattr(repsys_module, "commands")
44        command_module = getattr(commands_module, command)
45    except (ImportError, AttributeError):
46        if debug:
47            import traceback
48            traceback.print_exc()
49            sys.exit(1)
50        raise Error, "invalid command '%s'" % command
51    command_module.main()
52   
53if __name__ == "__main__":
54    do_command(parse_options, dispatch_command)
55
56# vim:et:ts=4:sw=4
Note: See TracBrowser for help on using the repository browser.