Skip to content

Commit cdc7a5f

Browse files
authored
Merge pull request #40 from JdeRobot/issue-39
Autodetection in manager.py
2 parents 8cdac85 + ac201b1 commit cdc7a5f

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

manager/libs/applications/compatibility/robotics_application_wrapper.py

+2-12
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ def __init__(self, update_callback):
2828
self.start_console()
2929
self.user_process = None
3030
self.entrypoint_path = None
31-
self.python_command = "python"
32-
self.check_python_version()
3331

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

4947
def run(self):
50-
self.user_process = self._create_process(f"DISPLAY=:2 {self.python_command} {self.entrypoint_path}")
48+
self.user_process = self._create_process(f"DISPLAY=:2 python3 {self.entrypoint_path}")
5149
self.running = True
5250

5351
def stop(self):
@@ -96,12 +94,4 @@ def suspend_resume(self, signal):
9694
if(signal == "resume"):
9795
p.resume()
9896
except psutil.NoSuchProcess:
99-
pass
100-
101-
def check_python_version(self):
102-
output = subprocess.check_output(['bash', '-c', 'echo $ROS_VERSION'])
103-
output_str = output.decode('utf-8')
104-
if (output_str == 1):
105-
self.python_command = "python"
106-
else:
107-
self.python_command = "python3"
97+
pass

manager/manager/manager.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import base64
1212
from queue import Queue
1313
from uuid import uuid4
14-
14+
import subprocess
1515

1616

1717
from src.manager.manager.launcher.launcher_engine import LauncherEngine
@@ -64,7 +64,8 @@ class Manager:
6464
]
6565

6666
def __init__(self, host: str, port: int):
67-
self.version = "5.1.0"
67+
self.version = "5.1.0"
68+
self.ros_version = self.get_ros_version()
6869
self.__code_loaded = False
6970
self.exercise_id = None
7071
self.machine = Machine(model=self, states=Manager.states, transitions=Manager.transitions,
@@ -288,6 +289,9 @@ def signal_handler(sign, frame):
288289
self.consumer.send_message(ex)
289290
LogManager.logger.error(e, exc_info=True)
290291

292+
def get_ros_version(self):
293+
output = subprocess.check_output(['bash', '-c', 'echo $ROS_VERSION'])
294+
return output.decode('utf-8')
291295

292296
if __name__ == "__main__":
293297
import argparse

0 commit comments

Comments
 (0)