root/releases/pkgcore/0.2.14/bin/pwrapper_installed @ marienz%2540gentoo.org-20061027035730-eafc81fa7bebbee9

Revision marienz%2540gentoo.org-20061027035730-eafc81fa7bebbee9, 1.1 KB (checked in by Marien Zwart <marienz@…>, 2 years ago)

Subcommand support for util.commandline.

  • Property executable set to True
Line 
1#!/usr/bin/env python
2
3"""Wrapper script that runs a pkgcore script from sys.path."""
4
5import os.path as osp
6import sys
7
8if __name__ == '__main__':
9    try:
10        from pkgcore.util import modules, commandline
11    except ImportError:
12        print >> sys.stderr, 'Cannot import pkgcore!'
13        print >> sys.stderr, 'Verify it is properly installed and/or ' \
14            'PYTHONPATH is set correctly.'
15        print >> sys.stderr, 'Add --debug to the commandline for a traceback.'
16        if '--debug' in sys.argv:
17            raise
18        sys.exit(1)
19
20    name = osp.basename(sys.argv[0])
21    try:
22        script = modules.load_module('pkgcore.scripts.%s' % (name,))
23    except modules.FailedImport:
24        print >> sys.stderr, 'Cannot load script %s.' % (name,)
25        print >> sys.stderr, 'Add --debug to the commandline for a traceback.'
26        if '--debug' in sys.argv:
27            raise
28        sys.exit(1)
29    else:
30        subcommands = getattr(script, 'commandline_commands', None)
31        if subcommands is None:
32            subcommands = {None: (script.OptionParser, script.main)}
33        commandline.main(subcommands)
Note: See TracBrowser for help on using the browser.