mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
In Windows, add startupinfo to subprocess calls to prevent terminal windows from opening in the background
This commit is contained in:
parent
400b8d2b83
commit
791d930a55
3 changed files with 21 additions and 3 deletions
|
@ -341,3 +341,11 @@ class Common(object):
|
|||
pass
|
||||
|
||||
return pdf_viewers
|
||||
|
||||
def get_subprocess_startupinfo(self):
|
||||
if platform.system() == "Windows":
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
return startupinfo
|
||||
else:
|
||||
return None
|
||||
|
|
|
@ -28,7 +28,11 @@ def is_docker_installed(common):
|
|||
def is_docker_ready(common):
|
||||
# Run `docker ps` without an error
|
||||
try:
|
||||
subprocess.run([common.container_runtime, "ps"], check=True)
|
||||
subprocess.run(
|
||||
[common.container_runtime, "ps"],
|
||||
check=True,
|
||||
startupinfo=common.get_subprocess_startupinfo(),
|
||||
)
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
|
@ -36,7 +40,9 @@ def is_docker_ready(common):
|
|||
|
||||
def launch_docker_windows():
|
||||
docker_desktop_path = "C:\\Program Files\\Docker\\Docker\\Docker Desktop.exe"
|
||||
subprocess.Popen([docker_desktop_path])
|
||||
subprocess.Popen(
|
||||
[docker_desktop_path], startupinfo=common.get_subprocess_startupinfo()
|
||||
)
|
||||
|
||||
|
||||
class DockerInstaller(QtWidgets.QDialog):
|
||||
|
@ -278,7 +284,10 @@ class Installer(QtCore.QThread):
|
|||
elif platform.system() == "Windows":
|
||||
try:
|
||||
# Run the installer
|
||||
subprocess.run([self.installer_filename])
|
||||
subprocess.run(
|
||||
[self.installer_filename],
|
||||
startupinfo=common.get_subprocess_startupinfo(),
|
||||
)
|
||||
self.install_finished.emit()
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
@ -31,6 +31,7 @@ class TaskBase(QtCore.QThread):
|
|||
stderr=subprocess.PIPE,
|
||||
bufsize=1,
|
||||
universal_newlines=True,
|
||||
startupinfo=self.common.get_subprocess_startupinfo(),
|
||||
) as p:
|
||||
if watch == "stdout":
|
||||
pipe = p.stdout
|
||||
|
|
Loading…
Reference in a new issue