Skip to content

Commit

Permalink
Merge pull request #35 from JdeRobot/issue-34
Browse files Browse the repository at this point in the history
Added ROS2 applications compatibility
  • Loading branch information
ReyDoran authored Jun 16, 2023
2 parents ce089e4 + 958d337 commit 94c011e
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def __init__(self, update_callback):
self.start_console()
self.user_process = None
self.entrypoint_path = None
self.python_command = "python"
self.check_python_version()

def _create_process(self, cmd):
#print("creando procesos")
Expand All @@ -45,7 +47,7 @@ def load_code(self, path: str):
self.entrypoint_path = path

def run(self):
self.user_process = self._create_process(f"DISPLAY=:2 python {self.entrypoint_path}")
self.user_process = self._create_process(f"DISPLAY=:2 {self.python_command} {self.entrypoint_path}")
self.running = True

def stop(self):
Expand Down Expand Up @@ -94,4 +96,12 @@ def suspend_resume(self, signal):
if(signal == "resume"):
p.resume()
except psutil.NoSuchProcess:
pass
pass

def check_python_version(self):
output = subprocess.check_output(['bash', '-c', 'echo $ROS_VERSION'])
output_str = output.decode('utf-8')
if (output_str == 1):
self.python_command = "python"
else:
self.python_command = "python3"

0 comments on commit 94c011e

Please sign in to comment.