Make docker installer work the same way for Windows too

This commit is contained in:
Micah Lee 2020-02-26 14:01:43 -08:00
parent 2d4ca86985
commit e18a898497
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
2 changed files with 10 additions and 29 deletions

View file

@ -55,7 +55,7 @@ def main(filename):
return return
# See if we need to install Docker... # See if we need to install Docker...
if platform.system() == "Darwin" and ( if (platform.system() == "Darwin" or platform.system() == "Windows") and (
not is_docker_installed(common) or not is_docker_ready(common) not is_docker_installed(common) or not is_docker_ready(common)
): ):
print("Docker is either not installed or not running") print("Docker is either not installed or not running")
@ -63,30 +63,6 @@ def main(filename):
docker_installer.start() docker_installer.start()
return return
if platform.system() == "Windows":
if not is_docker_installed(common):
print("Docker is not installed")
docker_installer = DockerInstaller(common)
docker_installer.start()
# Quit after the installer runs, because it requires rebooting
return
if not is_docker_ready(common):
print("Docker is not running")
launch_docker_windows(common)
# Wait up to 20 minutes for docker to be ready
for i in range(120):
if is_docker_ready(common):
main(filename)
return
print("Waiting for docker to be available ...")
time.sleep(1)
# Give up
print("Docker not available, giving up")
# Main window # Main window
main_window = MainWindow(common) main_window = MainWindow(common)

View file

@ -52,7 +52,7 @@ class DockerInstaller(QtWidgets.QDialog):
self.setWindowTitle("dangerzone") self.setWindowTitle("dangerzone")
self.setWindowIcon(self.common.get_window_icon()) self.setWindowIcon(self.common.get_window_icon())
self.setMinimumHeight(160) self.setMinimumHeight(170)
label = QtWidgets.QLabel() label = QtWidgets.QLabel()
if platform.system() == "Darwin": if platform.system() == "Darwin":
@ -148,11 +148,11 @@ class DockerInstaller(QtWidgets.QDialog):
self.reject() self.reject()
if self.download_t: if self.download_t:
self.download_t.quit()
try: try:
os.remove(self.installer_filename) os.remove(self.installer_filename)
except: except:
pass pass
self.download_t.quit()
def open_finder_clicked(self): def open_finder_clicked(self):
if platform.system() == "Darwin": if platform.system() == "Darwin":
@ -164,7 +164,12 @@ class DockerInstaller(QtWidgets.QDialog):
self.accept() self.accept()
def start(self): def start(self):
if not os.path.isdir("/Applications/Docker.app"): if platform.system() == "Darwin":
docker_app_path = "/Applications/Docker.app"
else:
docker_app_path = "C:\\Program Files\\Docker\\Docker\\Docker Desktop.exe"
if not os.path.exists(docker_app_path):
self.download() self.download()
else: else:
self.task_label.setText( self.task_label.setText(
@ -173,7 +178,7 @@ class DockerInstaller(QtWidgets.QDialog):
self.progress.hide() self.progress.hide()
self.cancel_button.hide() self.cancel_button.hide()
self.open_finder_path = "/Applications/Docker.app" self.open_finder_path = docker_app_path
self.open_finder_button.show() self.open_finder_button.show()
return self.exec_() == QtWidgets.QDialog.Accepted return self.exec_() == QtWidgets.QDialog.Accepted