Skip to content

Commit dd34d5e

Browse files
authored
fix: ros2 import guards (#527)
1 parent faee54e commit dd34d5e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/rai_core/rai/tools/ros2/generic/actions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
try:
16-
pass
17-
except ImportError:
15+
import importlib.util
16+
17+
if importlib.util.find_spec("rclpy") is None:
1818
raise ImportError(
1919
"This is a ROS2 feature. Make sure ROS2 is installed and sourced."
2020
)

src/rai_core/rai/tools/ros2/generic/services.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
try:
16-
pass
17-
except ImportError:
15+
import importlib.util
16+
17+
if importlib.util.find_spec("rclpy") is None:
1818
raise ImportError(
1919
"This is a ROS2 feature. Make sure ROS2 is installed and sourced."
2020
)

src/rai_core/rai/tools/ros2/generic/topics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
try:
16-
pass
17-
except ImportError:
15+
import importlib.util
16+
17+
if importlib.util.find_spec("rclpy") is None:
1818
raise ImportError(
1919
"This is a ROS2 feature. Make sure ROS2 is installed and sourced."
2020
)

0 commit comments

Comments
 (0)