@ -6,20 +6,22 @@ from common.basedir import BASEDIR
class TextWindow ( ) :
class TextWindow ( ) :
def __init__ ( self , s ) :
def __init__ ( self , s , noop = False ) :
try :
# text window is only implemented for android currently
self . text_proc = subprocess . Popen ( [ " ./text " , s ] ,
self . text_proc = None
stdin = subprocess . PIPE ,
if not noop :
cwd = os . path . join ( BASEDIR , " selfdrive " , " ui " , " text " ) ,
try :
close_fds = True )
self . text_proc = subprocess . Popen ( [ " ./text " , s ] ,
except OSError :
stdin = subprocess . PIPE ,
self . text_proc = None
cwd = os . path . join ( BASEDIR , " selfdrive " , " ui " , " text " ) ,
close_fds = True )
except OSError :
self . text_proc = None
def get_status ( self ) :
def get_status ( self ) :
if self . text_proc is not None :
if self . text_proc is not None :
self . text_proc . poll ( )
self . text_proc . poll ( )
return self . text_proc . returncode
return self . text_proc . returncode
return None
return None
def __enter__ ( self ) :
def __enter__ ( self ) :
@ -31,10 +33,11 @@ class TextWindow():
self . text_proc = None
self . text_proc = None
def wait_for_exit ( self ) :
def wait_for_exit ( self ) :
while True :
if self . text_proc is not None :
if self . get_status ( ) == 1 :
while True :
return
if self . get_status ( ) == 1 :
time . sleep ( 0.1 )
return
time . sleep ( 0.1 )
def __del__ ( self ) :
def __del__ ( self ) :
self . close ( )
self . close ( )
@ -43,29 +46,6 @@ class TextWindow():
self . close ( )
self . close ( )
class FakeTextWindow ( TextWindow ) :
def __init__ ( self , s ) : # pylint: disable=super-init-not-called
pass
def get_status ( self ) :
return 1
def wait_for_exit ( self ) :
return
def __enter__ ( self ) :
return self
def update ( self , _ ) :
pass
def close ( self ) :
pass
def __exit__ ( self , exc_type , exc_value , traceback ) :
pass
if __name__ == " __main__ " :
if __name__ == " __main__ " :
text = """ Traceback (most recent call last):
text = """ Traceback (most recent call last):
File " ./controlsd.py " , line 608 , in < module >
File " ./controlsd.py " , line 608 , in < module >