Skip to content

Commit 535dfe6

Browse files
committed
Add first protorype of cpp user exercise
1 parent 0bfaa7a commit 535dfe6

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

manager/manager/manager.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,31 @@ def find_docker_console():
685685
LogManager.logger.info("User code not found")
686686
raise Exception("User code not found")
687687

688+
_, file_extension = os.path.splitext(entrypoint)
689+
690+
if file_extension == ".cpp":
691+
fds = os.listdir("/dev/pts/")
692+
console_fd = str(max(map(int, fds[:-1])))
693+
694+
os.system(
695+
'/bin/bash -c "cd /workspace/code; source /opt/ros/humble/setup.bash; colcon build --symlink-install; source install/setup.bash; cd ../.."'
696+
)
697+
698+
self.application_process = subprocess.Popen(
699+
[
700+
"source /workspace/code/install/setup.bash && ros2 run academy academyCode"
701+
],
702+
stdin=open("/dev/pts/" + console_fd, "r"),
703+
stdout=sys.stdout,
704+
stderr=subprocess.STDOUT,
705+
bufsize=1024,
706+
universal_newlines=True,
707+
shell=True,
708+
executable="/bin/bash",
709+
)
710+
self.unpause_sim()
711+
return
712+
688713
# Pass the linter
689714
errors = self.linter.evaluate_source_code(to_lint)
690715
failed_linter = False
@@ -718,7 +743,6 @@ def find_docker_console():
718743

719744
LogManager.logger.info("Run application transition finished")
720745

721-
722746
def on_terminate_application(self, event):
723747
"""
724748
Handle the 'terminate_application' event.

0 commit comments

Comments
 (0)