diff options
author | Tim Harder <radhermit@gmail.com> | 2015-02-07 09:31:00 -0800 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2015-02-07 09:31:00 -0800 |
commit | 1f0e0b63e23192352cdc44a07882253e2ec0af5a (patch) | |
tree | ce82a5c197ec9c1c2ea9f5abd0dd1a438092bd63 /bin/pwrapper | |
parent | util/commandline: add missing import_module import (diff) | |
download | pkgcore-1f0e0b63e23192352cdc44a07882253e2ec0af5a.tar.gz pkgcore-1f0e0b63e23192352cdc44a07882253e2ec0af5a.tar.bz2 pkgcore-1f0e0b63e23192352cdc44a07882253e2ec0af5a.zip |
simplify wrapper scripts
Diffstat (limited to 'bin/pwrapper')
-rwxr-xr-x | bin/pwrapper | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/bin/pwrapper b/bin/pwrapper index c7532e8dc..7fc2bda29 100755 --- a/bin/pwrapper +++ b/bin/pwrapper @@ -17,25 +17,19 @@ sys.path.insert(1, osp.dirname(osp.dirname(osp.abspath(__file__)))) if __name__ == '__main__': try: from pkgcore.util import commandline - except ImportError: - sys.stderr.write('Cannot import either snakeoil or pkgcore!\n') - sys.stderr.write('Verify they are properly installed and/or ' - 'PYTHONPATH is set correctly for python %s.\n' % - (".".join(map(str, sys.version_info[:3])),)) + name = osp.basename(sys.argv[0]).replace("-", "_") + script = import_module('pkgcore.scripts.%s' % (name,)) + except ImportError as e: + sys.stderr.write(str(e) + '!\n') + sys.stderr.write( + 'Verify that snakeoil and pkgcore are properly installed ' + 'and/or PYTHONPATH is set correctly for python %s.\n' % + (".".join(map(str, sys.version_info[:3])),)) if '--debug' in sys.argv: raise sys.stderr.write('Add --debug to the commandline for a traceback.\n') sys.exit(1) os.environ["PKGCORE_SCRIPT_PATH"] = osp.dirname(osp.abspath(__file__)) - name = osp.basename(sys.argv[0]).replace("-", "_") - try: - script = import_module('pkgcore.scripts.%s' % (name,)) - except ImportError: - sys.stderr.write('Cannot load script %s.\n' % (name,)) - if '--debug' in sys.argv: - raise - sys.stderr.write('Add --debug to the commandline for a traceback.\n') - sys.exit(1) subcommands = getattr(script, 'argparser', None) commandline.main(subcommands) |