diff --git a/manager/manager/docker_thread/docker_thread.py b/manager/manager/docker_thread/docker_thread.py index 9f5564b..4fda16a 100644 --- a/manager/manager/docker_thread/docker_thread.py +++ b/manager/manager/docker_thread/docker_thread.py @@ -6,7 +6,6 @@ - class DockerThread(threading.Thread): """Threaded Docker Thread Class""" def __init__(self, cmd, shell=True): @@ -17,7 +16,7 @@ def __init__(self, cmd, shell=True): def run(self): self.process = subprocess.Popen(self.cmd, shell=self.shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE, start_new_session=True, - bufsize=1024, universal_newlines=True) + bufsize=1024, universal_newlines=True, executable="/bin/bash") self.process.communicate() def terminate(self): diff --git a/manager/manager/launcher/launcher_ros2_api.py b/manager/manager/launcher/launcher_ros2_api.py index da9220a..17feb1b 100644 --- a/manager/manager/launcher/launcher_ros2_api.py +++ b/manager/manager/launcher/launcher_ros2_api.py @@ -29,10 +29,10 @@ def run(self, callback): if ACCELERATION_ENABLED: exercise_launch_cmd = ( - f"export VGL_DISPLAY={DRI_PATH}; vglrun ros2 launch {self.launch_file}" + f"source /.env;export VGL_DISPLAY={DRI_PATH}; vglrun ros2 launch {self.launch_file}" ) else: - exercise_launch_cmd = f"ros2 launch {self.launch_file}" + exercise_launch_cmd = f"source /.env;ros2 launch {self.launch_file}" exercise_launch_thread = DockerThread(exercise_launch_cmd) exercise_launch_thread.start() diff --git a/manager/manager/manager.py b/manager/manager/manager.py index 113fc84..f6ee149 100644 --- a/manager/manager/manager.py +++ b/manager/manager/manager.py @@ -295,20 +295,26 @@ def prepare_custom_universe(self, cfg_dict): if cfg_dict["zip"].startswith("data:"): _, _, zip_file = cfg_dict["zip"].partition("base64,") - universe_ref = "/workspace/worlds/" + cfg_dict["name"] - zip_destination = universe_ref + ".zip" - with open(zip_destination, "wb") as result: - result.write(base64.b64decode(zip_file)) + universe_ref = "/workspace/worlds/src/" + cfg_dict["name"] + # Remove old content + if os.path.exists("/workspace/worlds"): + shutil.rmtree("/workspace/worlds", ignore_errors=False) # Create the folder if it doesn't exist universe_folder = universe_ref + "/" if not os.path.exists(universe_folder): os.makedirs(universe_folder) + zip_destination = universe_ref + ".zip" + with open(zip_destination, "wb") as result: + result.write(base64.b64decode(zip_file)) + zip_ref = zipfile.ZipFile(zip_destination, "r") zip_ref.extractall(universe_folder + "/") zip_ref.close() + os.system('/bin/bash -c "cd /workspace/worlds; source /opt/ros/humble/setup.bash; colcon build --symlink-install; source install/setup.bash; cd ../.."') + def on_prepare_visualization(self, event): LogManager.logger.info("Visualization transition started") @@ -328,7 +334,7 @@ def on_prepare_visualization(self, event): self.gui_server = Server(2303, self.update) self.gui_server.start() elif self.visualization_type in ["bt_studio", "bt_studio_gz"]: - self.gui_server = FileWatchdog('/tmp/tree_state', self.update_bt_studio) # TODO: change if type bt + self.gui_server = FileWatchdog('/tmp/tree_state', self.update_bt_studio) self.gui_server.start() LogManager.logger.info("Visualization transition finished") @@ -569,7 +575,6 @@ def on_code_autocomplete(self, event): except Exception as e: LogManager.logger.info('Error formating code' + str(e)) - def on_run_application(self, event): def find_docker_console(): """Search console in docker different of /dev/pts/0"""