Skip to content

Commit f1921fe

Browse files
Removed workspaces from ArgumentResolver and LaunchFileReader
1 parent c0b4521 commit f1921fe

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/roswire/proxy/launch/reader.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ def wrapped(self,
109109
class LaunchFileReader:
110110
_shell: dockerblade.Shell
111111
_files: dockerblade.FileSystem
112-
_workspaces: Sequence[str]
113112

114113
def _parse_file(self, fn: str) -> ET.Element:
115114
"""Parses a given XML launch file to a root XML element."""
@@ -469,7 +468,6 @@ def _resolve_args(self, s: str, ctx: LaunchContext) -> str:
469468
resolve_ctx = ctx.resolve_dict or {}
470469
resolver = ArgumentResolver(shell=self._shell,
471470
files=self._files,
472-
workspaces=self._workspaces,
473471
context=resolve_ctx)
474472
return resolver.resolve(s)
475473

src/roswire/proxy/launch/substitution.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010
__all__ = ('ArgumentResolver',)
1111

12-
from typing import Any, Dict, Match, Sequence
12+
from typing import Any, Dict, Match
1313
import os
1414
import re
1515
import shlex
@@ -29,7 +29,6 @@
2929
class ArgumentResolver:
3030
shell: dockerblade.Shell
3131
files: dockerblade.FileSystem
32-
workspaces: Sequence[str]
3332
context: Dict[str, Any] = attr.ib(default=None)
3433

3534
def _resolve_arg(self, s: str) -> str:
@@ -88,10 +87,14 @@ def _find_executable(self, package: str, path: str) -> str:
8887
path_original = path
8988

9089
# look for executable in lib/ directory of workspaces
91-
for path_workspace in self.workspaces:
92-
path_in_ws = os.path.join(path_workspace, 'lib', package, path)
93-
if self.files.access(path_in_ws, os.X_OK):
94-
return path_in_ws
90+
catkin_find_command = ("catkin_find --first-only --libexec "
91+
f"{shlex.quote(package)} {shlex.quote(path)}")
92+
try:
93+
path_in_ws = self.shell.check_output(catkin_find_command)
94+
path_in_ws = path_in_ws.strip()
95+
return path_in_ws
96+
except dockerblade.CalledProcessError:
97+
pass
9598

9699
# look for executable in source directory of package
97100
path_package = self._find_package_path(package)
@@ -103,10 +106,15 @@ def _find_executable(self, package: str, path: str) -> str:
103106
return path_in_package
104107

105108
def _find_resource(self, package: str, path: str) -> str:
106-
for path_workspace in self.workspaces:
107-
path_in_ws = os.path.join(path_workspace, 'share', package, path)
108-
if self.files.isfile(path_in_ws):
109-
return path_in_ws
109+
catkin_find_command = ("catkin_find --first-only --share "
110+
f"{shlex.quote(package)} {shlex.quote(path)}")
111+
try:
112+
path_in_ws = self.shell.check_output(catkin_find_command)
113+
path_in_ws = path_in_ws.strip()
114+
return path_in_ws
115+
except dockerblade.CalledProcessError:
116+
pass
117+
110118
path_package = self._find_package_path(package)
111119
path_in_package = os.path.join(path_package, path)
112120
if not self.files.isfile(path_in_package):

0 commit comments

Comments
 (0)