def test_distribution_variant(self): is_Ubuntu() is_Debian() is_Raspbian() is_Fedora() is_Arch() is_CentOS() is_RedHat() is_WSL()
def exec_dialog_subprocess(cmd): try: log("exec_dialog_subprocess(%s)", cmd) kwargs = {} if POSIX: kwargs["close_fds"] = True else: #win32 platform code would create a log file for the command's output, #tell it not to do that: env = os.environ.copy() env["XPRA_LOG_TO_FILE"] = "0" kwargs["env"] = env proc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, **kwargs) if is_WSL(): #WSL needs to wait before calling communicate? proc.wait() stdout, stderr = proc.communicate() log("exec_dialog_subprocess(%s)", cmd) if stderr: log.warn("Warning: dialog process error output:") for x in stderr.splitlines(): log.warn(" %s", x) return proc.returncode, stdout except Exception as e: log("exec_dialog_subprocess(..)", exc_info=True) log.error("Error: failed to execute the dialog subcommand") log.error(" %s", e) return -1, None
def exec_dialog_subprocess(cmd): try: log("exec_dialog_subprocess(%s)", cmd) kwargs = {} if POSIX: kwargs["close_fds"] = True else: #win32 platform code would create a log file for the command's output, #tell it not to do that: env = os.environ.copy() env["XPRA_LOG_TO_FILE"] = "0" kwargs["env"] = env proc = Popen(cmd, stdout=PIPE, stderr=PIPE, **kwargs) stdout = [] stderr = [] from xpra.gtk_common.gobject_compat import import_gtk gtk = import_gtk() def read_thread(fd, out): while proc.poll() is None: try: v = fd.read() if v: out.append(v) except: time.sleep(0.1) try: gtk.main_quit() except: pass from xpra.make_thread import start_thread start_thread(read_thread, "dialog-stdout-reader", True, (proc.stdout, stdout)) start_thread(read_thread, "dialog-stderr-reader", True, (proc.stderr, stderr)) if is_WSL(): #WSL needs to wait before calling communicate, #is this still needed now that we read using threads? proc.wait() gtk.main() log("exec_dialog_subprocess(%s) returncode=%s", cmd, proc.poll()) if stderr: log.warn("Warning: dialog process error output:") for x in (b"".join(stderr)).decode().splitlines(): log.warn(" %s", x) return proc.returncode, (b"".join(stdout)).decode() except Exception as e: log("exec_dialog_subprocess(..)", exc_info=True) log.error("Error: failed to execute the dialog subcommand") log.error(" %s", e) return -1, None