From 52003f3be339c99ba3d8b7ef310ab555fd1ada06 Mon Sep 17 00:00:00 2001 From: Tobias Fischer Date: Thu, 6 May 2021 08:34:09 +1000 Subject: [PATCH 1/2] Port https://github.com/ros-infrastructure/rosdep/pull/661 --- src/rosdep2/installers.py | 2 +- src/rosdep2/main.py | 9 ++++++--- src/rosdep2/platforms/source.py | 1 + src/rosdep2/shell_utils.py | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/rosdep2/installers.py b/src/rosdep2/installers.py index 2f4c1cd1e..72c913061 100644 --- a/src/rosdep2/installers.py +++ b/src/rosdep2/installers.py @@ -325,7 +325,7 @@ def __init__(self, detect_fn, supports_depends=False): self.detect_fn = detect_fn self.supports_depends = supports_depends self.as_root = True - self.sudo_command = 'sudo -H' if os.geteuid() != 0 else '' + self.sudo_command = 'sudo -H' if hasattr(os, 'geteuid') and os.geteuid() != 0 else '' def elevate_priv(self, cmd): """ diff --git a/src/rosdep2/main.py b/src/rosdep2/main.py index 268fcbdc1..bde2fbf65 100644 --- a/src/rosdep2/main.py +++ b/src/rosdep2/main.py @@ -153,7 +153,10 @@ def rosdep_main(args=None): except UsageError as e: print(_usage, file=sys.stderr) print('ERROR: %s' % (str(e)), file=sys.stderr) - sys.exit(os.EX_USAGE) + if hasattr(os, 'EX_USAGE'): + sys.exit(os.EX_USAGE) + else: + sys.exit() except RosdepInternalError as e: print(""" ERROR: Rosdep experienced an internal error. @@ -499,9 +502,9 @@ def _package_args_handler(command, parser, options, args): if command in ['install', 'check', 'keys'] and options.ignore_src: if options.verbose: print('Searching ROS_PACKAGE_PATH for ' - 'sources: ' + str(os.environ['ROS_PACKAGE_PATH'].split(':'))) + 'sources: ' + str(os.environ['ROS_PACKAGE_PATH'].split(os.pathsep))) ws_pkgs = get_workspace_packages() - for path in os.environ['ROS_PACKAGE_PATH'].split(':'): + for path in os.environ['ROS_PACKAGE_PATH'].split(os.pathsep): path = os.path.abspath(path.strip()) if os.path.exists(path): pkgs = find_catkin_packages_in(path, options.verbose) diff --git a/src/rosdep2/platforms/source.py b/src/rosdep2/platforms/source.py index 862494b72..3ba17fedc 100644 --- a/src/rosdep2/platforms/source.py +++ b/src/rosdep2/platforms/source.py @@ -302,6 +302,7 @@ def install_source(resolved): rd_debug('Extracting tarball') tarf = tarfile.open(filename) tarf.extractall(tempdir) + tarf.close() else: rd_debug('Bypassing tarball extraction as it is a dmg') rd_debug('Running installation script') diff --git a/src/rosdep2/shell_utils.py b/src/rosdep2/shell_utils.py index f0cca1396..8dde39155 100644 --- a/src/rosdep2/shell_utils.py +++ b/src/rosdep2/shell_utils.py @@ -84,7 +84,8 @@ def create_tempfile_from_string_and_execute(string_script, path=None, exec_fn=No result = 1 try: - fh = tempfile.NamedTemporaryFile('w', delete=False) + script_ext = '.bat' if os.name == 'nt' else '' + fh = tempfile.NamedTemporaryFile('w', suffix=script_ext, delete=False) fh.write(string_script) fh.close() rd_debug('Executing script below with cwd=%s\n{{{\n%s\n}}}\n' % (path, string_script)) From c00d7cf4ea0d6f4b911277283f794457cfd7803c Mon Sep 17 00:00:00 2001 From: Tobias Fischer Date: Mon, 28 Jun 2021 06:54:05 +1000 Subject: [PATCH 2/2] Return non-zero on Windows --- src/rosdep2/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rosdep2/main.py b/src/rosdep2/main.py index bde2fbf65..457f3de18 100644 --- a/src/rosdep2/main.py +++ b/src/rosdep2/main.py @@ -156,7 +156,7 @@ def rosdep_main(args=None): if hasattr(os, 'EX_USAGE'): sys.exit(os.EX_USAGE) else: - sys.exit() + sys.exit(64) # EX_USAGE is not available on Windows; EX_USAGE is 64 on Unix except RosdepInternalError as e: print(""" ERROR: Rosdep experienced an internal error.