mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 21:14:01 +08:00
* cause error * revert for now * decrease font by 10 pts * remove unnecessary () for class ;) * move exit button closer to right corner * 70% transparency for black background * cause error * well that's not right * try showing more lines * actually show last three lines * forgot to join * debug what we can leave out * show last four files * revert * show 3 lines and one extra for last erroring line * increase by 5 points * move text left a bit * fix * fix * two more lines * add double indentation for formatting * remove indentation of file lines * fix * fix * try this * try this * make lines shorter * clean up error code in manager * try one more * reduce lines altered in PR * four is good * this actually isn't required anymore * can move more left * and increase size * slightly less * slightly less * try a different error * try last three with negative * revert to 75 * fix * clean up * remove path hiding * revert offsets * revert
67 lines
1.6 KiB
Python
Executable File
67 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import os
|
|
import time
|
|
import subprocess
|
|
from common.basedir import BASEDIR
|
|
|
|
|
|
class TextWindow:
|
|
def __init__(self, s, noop=False):
|
|
# text window is only implemented for android currently
|
|
self.text_proc = None
|
|
if not noop:
|
|
try:
|
|
self.text_proc = subprocess.Popen(["./text", s],
|
|
stdin=subprocess.PIPE,
|
|
cwd=os.path.join(BASEDIR, "selfdrive", "ui", "text"),
|
|
close_fds=True)
|
|
except OSError:
|
|
self.text_proc = None
|
|
|
|
def get_status(self):
|
|
if self.text_proc is not None:
|
|
self.text_proc.poll()
|
|
return self.text_proc.returncode
|
|
return None
|
|
|
|
def __enter__(self):
|
|
return self
|
|
|
|
def close(self):
|
|
if self.text_proc is not None:
|
|
self.text_proc.terminate()
|
|
self.text_proc = None
|
|
|
|
def wait_for_exit(self):
|
|
if self.text_proc is not None:
|
|
while True:
|
|
if self.get_status() == 1:
|
|
return
|
|
time.sleep(0.1)
|
|
|
|
def __del__(self):
|
|
self.close()
|
|
|
|
def __exit__(self, exc_type, exc_value, traceback):
|
|
self.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
text = """Traceback (most recent call last):
|
|
File "./controlsd.py", line 608, in <module>
|
|
main()
|
|
File "./controlsd.py", line 604, in main
|
|
controlsd_thread(sm, pm, logcan)
|
|
File "./controlsd.py", line 455, in controlsd_thread
|
|
1/0
|
|
ZeroDivisionError: division by zero"""
|
|
print(text)
|
|
|
|
with TextWindow(text) as s:
|
|
for _ in range(100):
|
|
if s.get_status() == 1:
|
|
print("Got exit button")
|
|
break
|
|
time.sleep(0.1)
|
|
print("gone")
|