def main(url=None): app = QtWidgets.QApplication(sys.argv) if url: main_window = webbrowser.MainWindow(url) main_window.show() else: base_dir = utils.get_base_dir() os.chdir(base_dir) _config_logging(base_dir) controller = Controller(deployment_worker.Worker()) main_window = MainWindow(controller) splash = _create_splash_window(main_window) controller.set_splash_window(splash) controller.show_splash() loop = trollius.get_event_loop() loop.set_exception_handler(_async_exception_handler) # Need to run trollius event loop in a separate thread due to Qt event loop thread = threading.Thread(target=_run_async_loop, args=(loop, )) thread.start() exit_code = app.exec_() loop.call_soon_threadsafe(loop.stop) thread.join() loop.close() sys.exit(exit_code)
def _read_console(self): base_dir = utils.get_base_dir() console_log_file = os.path.join( base_dir, "%s-console.log" % constants.PRODUCT_NAME) buf = "" menu_done = False with open(console_log_file, 'ab') as console_log_file: with open(self._console_named_pipe, 'rb') as vm_console_pipe: while True: data = vm_console_pipe.readline() # Exit loop when the VM reboots if not data: LOG.debug("Console: no more data") break # NOTE: Workaround due to formatting issues with menu.c32 # TODO: Needs to be fixed in term.js if not menu_done: buf += data if b'\x1b' not in buf: self._stdout_callback(data) idx = buf.find(b"\x1b[0m") if idx >= 0: self._stdout_callback(buf[idx + len(b"\x1b[0m"):]) menu_done = True buf = b"" LOG.debug("Console: pxelinux menu done") else: self._stdout_callback(data) console_log_file.write(data) # TODO(alexpilotti): Fix why the heck CentOS gets stuck # instead of rebooting and remove this awful workaround :) if data.find("Reached target Shutdown.") != -1: LOG.debug("Console: reached target Shutdown") break if data.find("Warning: Could not boot.") != -1: raise exceptions.CouldNotBootException()