From c8385f4b55173c10c33c165d375f3aadfb947644 Mon Sep 17 00:00:00 2001 From: James Pace Date: Sun, 23 Nov 2025 06:55:13 -0500 Subject: [PATCH] Add env. --- am_i_up/am_i_up.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/am_i_up/am_i_up.py b/am_i_up/am_i_up.py index 4206456..0de3ffc 100644 --- a/am_i_up/am_i_up.py +++ b/am_i_up/am_i_up.py @@ -22,7 +22,8 @@ def main(): web.get('/', routes.root), web.get('/ping', routes.ping), web.get('/uptime', routes.uptime), - web.get('/build_info', routes.build_info) + web.get('/build_info', routes.build_info), + web.get('/env', routes.env) ]) web.run_app(app) @@ -33,6 +34,20 @@ class Facts: def get_uptime(self): return time.monotonic() - self._start_time + def get_env(self): + env = {} + # We're not going to return the whole environment because + # of security. + # Let's pick the ones we want. + env['ROS_AUTOMATIC_DISCOVERY_RANGE'] = os.environ.get('ROS_AUTOMATIC_DISCOVERY_RANGE', None) + env['AMENT_PREFIX_PATH'] = os.environ.get('AMENT_PREFIX_PATH', None) + env['ROS_DISTRO'] = os.environ.get('ROS_DISTRO', None) + env['RMW_IMPLEMENTATION'] = os.environ.get('RMW_IMPLEMENTATION', None) + env['ROS_NAMESPACE'] = os.environ.get('ROS_NAMESPACE', None) + env['CYCLONEDDS_URI'] = os.environ.get('CYCLONEDDS_URI', None) + + return env + def get_buildinfo(self): # Find the share directory for 'build_info_getter'. build_info_getter_directory = None @@ -77,5 +92,6 @@ class Routes: project_state["status"] = True return web.json_response(project_state) - - + async def env(self, request): + env = self._facts.get_env() + return web.json_response(env)