From 2ca5028af8142e71c7c002be2ae7c372d0b2d70b Mon Sep 17 00:00:00 2001 From: Sean Yen Date: Sat, 18 Aug 2018 22:24:37 -0700 Subject: [PATCH 1/2] use console_scripts to generate portable wstool. --- scripts/wstool | 64 ---------------------------------------- setup.py | 4 ++- src/wstool/wstool_cli.py | 12 ++++++++ 3 files changed, 15 insertions(+), 65 deletions(-) delete mode 100755 scripts/wstool diff --git a/scripts/wstool b/scripts/wstool deleted file mode 100755 index 03a4bb3..0000000 --- a/scripts/wstool +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# Software License Agreement (BSD License) -# -# Copyright (c) 2010, Willow Garage, Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of Willow Garage, Inc. nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# Revision $Id: rosws 14389 2011-07-20 18:38:40Z tfoote $ -# $Author: tfoote $ - -"""%(prog)s is a command to manipulate ROS workspaces. - -Official usage: - %(prog)s CMD [ARGS] [OPTIONS] - -%(prog)s will try to infer install path from context -"%(prog)s init" replaces the rosinstall command - -Type '%(prog)s --help' for usage. -""" - -from __future__ import print_function -import sys - -try: - import wstool.wstool_cli - from wstool.common import MultiProjectException -except ImportError as exc: - sys.exit("ERROR: Cannot find required rosinstall library version, \ -check your installation (also of vcstools) is up-to-date. One frequent cause \ -is that rosinstall 0.5 is still installed in /usr/local/lib.\n%s" % exc) - - -if __name__ == "__main__": - try: - sys.exit(wstool.wstool_cli.wstool_main(sys.argv)) - except MultiProjectException as mpe: - sys.exit("ERROR in config: %s" % str(mpe)) diff --git a/setup.py b/setup.py index 1ff0625..fcc5d77 100644 --- a/setup.py +++ b/setup.py @@ -123,7 +123,9 @@ def run(self): }, # tests_require automatically installed when running python setup.py test tests_require=test_required, - scripts=["scripts/wstool"], + entry_points = { + 'console_scripts': ['wstool=wstool.wstool_cli:main'] + }, author="Tully Foote", author_email="tfoote@osrfoundation.org", url="http://wiki.ros.org/wstool", diff --git a/src/wstool/wstool_cli.py b/src/wstool/wstool_cli.py index 44f3ac1..81063be 100644 --- a/src/wstool/wstool_cli.py +++ b/src/wstool/wstool_cli.py @@ -186,3 +186,15 @@ def wstool_main(argv=None, usage=None): except KeyboardInterrupt: return 1 + + +def main(): + try: + from .common import MultiProjectException + sys.exit(wstool_main(sys.argv)) + except ImportError as exc: + sys.exit("ERROR: Cannot find required rosinstall library version, \ + check your installation (also of vcstools) is up-to-date. One frequent cause \ + is that rosinstall 0.5 is still installed in /usr/local/lib.\n%s" % exc) + except MultiProjectException as mpe: + sys.exit("ERROR in config: %s" % str(mpe)) From 6b06c4f8cb33963c664452eba119d540937ec7cf Mon Sep 17 00:00:00 2001 From: Sean Yen Date: Thu, 31 Jan 2019 15:37:21 -0800 Subject: [PATCH 2/2] style fix. --- src/wstool/wstool_cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wstool/wstool_cli.py b/src/wstool/wstool_cli.py index 81063be..94abab0 100644 --- a/src/wstool/wstool_cli.py +++ b/src/wstool/wstool_cli.py @@ -193,8 +193,8 @@ def main(): from .common import MultiProjectException sys.exit(wstool_main(sys.argv)) except ImportError as exc: - sys.exit("ERROR: Cannot find required rosinstall library version, \ - check your installation (also of vcstools) is up-to-date. One frequent cause \ - is that rosinstall 0.5 is still installed in /usr/local/lib.\n%s" % exc) + sys.exit("ERROR: Cannot find required rosinstall library version, " + "check your installation (also of vcstools) is up-to-date. One frequent cause " + "is that rosinstall 0.5 is still installed in /usr/local/lib.\n%s" % exc) except MultiProjectException as mpe: sys.exit("ERROR in config: %s" % str(mpe))