Skip to content

Commit

Permalink
webui: Saving webui-desktop log to anaconda.log
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkankovsky committed Aug 22, 2024
1 parent e2262be commit c1a4fb1
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions pyanaconda/ui/webui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from pyanaconda import ui
from pyanaconda.anaconda_loggers import get_module_logger
from pyanaconda.anaconda_logging import program_log_lock
from pyanaconda.core.constants import QUIT_MESSAGE, PAYLOAD_TYPE_DNF, WEBUI_VIEWER_PID_FILE, \
BACKEND_READY_FLAG_FILE
from pyanaconda.core.util import startProgram
Expand Down Expand Up @@ -141,14 +142,39 @@ def _run_webui(self):
# FIXME: We probably want to move this to early execution similar to what we have on live
profile_name = FIREFOX_THEME_DEFAULT

proc = startProgram(["/usr/libexec/webui-desktop",
"-t", profile_name, "-r", str(int(self.remote)),
"/cockpit/@localhost/anaconda-webui/index.html"],
reset_lang=False)
log.debug("cockpit web view has been started")
with open(self._viewer_pid_file, "w") as f:
f.write(repr(proc.pid))
proc.wait()
try:
proc = startProgram(
["/usr/libexec/webui-desktop",
"-t", profile_name, "-r", str(int(self.remote)),
"/cockpit/@localhost/anaconda-webui/index.html"],
reset_lang=False
)

with open(self._viewer_pid_file, "w") as f:
f.write(repr(proc.pid))

(output_string, err_string) = proc.communicate()

output_string = output_string.decode("utf-8")
if output_string and output_string[-1] != "\n":
output_string = output_string + "\n"

log.debug("ddddd output: %s errors: %s", output_string, err_string)

with program_log_lock:
if output_string:
for line in output_string.splitlines():
log.info(line)

if err_string:
log.error("Errors from webui-desktop:")
for line in err_string.splitlines():
log.error(line)
proc.wait()
except OSError as e:
with program_log_lock:
log.error("Error running webui-desktop: %s", e.strerror)
raise

def _watch_webui_on_live(self):
"""Watch webui-desktop script process on Live.
Expand Down

0 comments on commit c1a4fb1

Please sign in to comment.