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