mirror of
https://github.com/lutris/lutris
synced 2024-11-05 18:10:49 +00:00
Replace logging output with GLib IO watch
This commit is contained in:
parent
6f3fa0fcdf
commit
bdd28ab562
1 changed files with 7 additions and 9 deletions
|
@ -111,20 +111,18 @@ class LutrisThread(threading.Thread):
|
|||
self.game_process = self.execute_process(self.command, env)
|
||||
if not self.game_process:
|
||||
return
|
||||
for line in iter(self.game_process.stdout.readline, b''):
|
||||
if not self.is_running:
|
||||
break
|
||||
try:
|
||||
line = line.decode()
|
||||
except UnicodeDecodeError:
|
||||
line = ''
|
||||
if not line:
|
||||
continue
|
||||
|
||||
GLib.io_add_watch(self.game_process.stdout, GLib.IO_IN, self.on_stdout_output)
|
||||
|
||||
def on_stdout_output(self, fd, condition):
|
||||
line = fd.readline().decode(errors='replace')
|
||||
if line:
|
||||
self.stdout += line
|
||||
if self.debug_output:
|
||||
with contextlib.suppress(BlockingIOError):
|
||||
sys.stdout.write(line)
|
||||
sys.stdout.flush()
|
||||
return True
|
||||
|
||||
def run_in_terminal(self):
|
||||
"""Write command in a script file and run it.
|
||||
|
|
Loading…
Reference in a new issue