Handle eris being run without a tty.

- i.e. being run in a pipe or redirection.
- Just outputting the log.
This commit is contained in:
Andrew Hamilton 2020-04-25 22:08:59 +10:00
parent 1e66589f11
commit 388e3af932

View file

@ -594,6 +594,9 @@ class Log:
timestamp = (time.strftime("%H:%M:%S", time.localtime()) timestamp = (time.strftime("%H:%M:%S", time.localtime())
if timestamp is None else timestamp) if timestamp is None else timestamp)
line = termstr.TermStr(timestamp, Log._GREY_BOLD_STYLE) + " " + message line = termstr.TermStr(timestamp, Log._GREY_BOLD_STYLE) + " " + message
if not sys.stdout.isatty():
print(line, flush=True)
return
self.lines.append(line) self.lines.append(line)
self._appearance = None self._appearance = None
self._appearance_changed_event.set() self._appearance_changed_event.set()
@ -1141,8 +1144,15 @@ def main(root_path, loop, worker_count=None, editor_command=None, theme=None,
time.sleep(0.05) time.sleep(0.05)
screen.stop_workers() screen.stop_workers()
loop.stop() loop.stop()
fill3.main(loop, appearance_changed_event, screen, exit_loop=exit_loop) if sys.stdout.isatty():
log.log_message("Program stopped.") fill3.main(loop, appearance_changed_event, screen, exit_loop=exit_loop)
log.log_message("Program stopped.")
else:
try:
loop.run_forever()
except KeyboardInterrupt:
screen.stop_workers()
loop.stop()
finally: finally:
notifier.stop() notifier.stop()
if summary.is_loaded: if summary.is_loaded: