Skip to content

Commit

Permalink
Merge pull request #159 from JdeRobot/issue-158
Browse files Browse the repository at this point in the history
Fixed console debug
  • Loading branch information
javizqh authored Sep 12, 2024
2 parents fd39152 + b5d685f commit 8b38724
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions manager/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,25 @@ def add_frequency_control(self, code):
code = code + frequency_control_code_post
return code


def on_run_application(self, event):
def find_docker_console():
"""Search console in docker different of /dev/pts/0"""
pts_consoles = [f"/dev/pts/{dev}" for dev in os.listdir('/dev/pts/') if dev.isdigit()]
consoles = []
for console in pts_consoles:
if console != "/dev/pts/0":
try:
# Search if it's a console
with open(console, 'w') as f:
f.write("")
consoles.append(console)
except Exception:
# Continue searching
continue

# raise Exception("No active console other than /dev/pts/0")
return consoles

code_path = "/workspace/code/exercise.py"
# Extract app config
Expand Down Expand Up @@ -331,11 +349,14 @@ def on_run_application(self, event):
)
self.unpause_sim()
else:
with open('/dev/pts/1', 'w') as console:
console.write(errors + "\n\n")
console_path = find_docker_console()
for i in console_path:
with open(i, 'w') as console:
console.write(errors + "\n\n")

raise Exception(errors)


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

def run_bt_studio_application(self, data):
Expand Down

0 comments on commit 8b38724

Please sign in to comment.