def exec_system_batch(self): if not self.system_batch_file_exists(): logger.warning("The batch file does not exist! Did you unzip and copy the support files?") return False logger.info("The batch file must be executed as administrator with all other users logged off the system!") if Helper.is_user_admin(): os.system(self.system_batch_file()) return True else: ctypes.windll.shell32.ShellExecuteW(None, "runas", self.system_batch_file(), "", None, 1) return True
def noaa_support_install(self): logger.debug("installing NOAA Support Files") noaa_support = NOAASupport(app_info=self._ai, lib_info=self._li, progress=QtProgress(parent=self)) msg = "The batch file must be executed as administrator\n" \ "with all other users logged off the system.\n" \ "Once executed, follow the instructions in the Windows shell.\n\n" \ "Do you want to continue with the installation?" # noinspection PyCallByClass,PyArgumentList ret = QtWidgets.QMessageBox.information( self, "Install files", msg, QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) if ret == QtWidgets.QMessageBox.No: return if not noaa_support.system_noaa_support_folder_present(): msg = "The support folder is not present!\n" \ "Did you copy it? Go to step #2." # noinspection PyCallByClass,PyArgumentList QtWidgets.QMessageBox.information(self, "Install files", msg, QtWidgets.QMessageBox.Ok) return if not noaa_support.system_batch_file_exists(): msg = "The batch file does not exist!\n" \ "Did you execute steps #1 and #2? Try to execute them again." # noinspection PyCallByClass,PyArgumentList QtWidgets.QMessageBox.information(self, "Install files", msg, QtWidgets.QMessageBox.Ok) return if not Helper.is_user_admin(): msg = "CA Tools was not executed as admin!\n\n" \ "Do you want that CA Tools executes the batch file?\n\n" \ "You will be prompted for permissions.\n" # noinspection PyCallByClass,PyArgumentList ret = QtWidgets.QMessageBox.information( self, "Install files", msg, QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) if ret == QtWidgets.QMessageBox.No: msg = "You have then two alternatives:\n" \ "#1: Close CA Tools and re-open it using the option \"Run as administrator\"\n" \ "or:\n" \ "#2: Manually run as administrator the batch file at:\n" \ "- %s\n\n" \ "For option #2, do you want that CA Tools open the folder with the batch file?" \ % (noaa_support.system_batch_file()) # noinspection PyCallByClass,PyArgumentList ret = QtWidgets.QMessageBox.information( self, "Install files", msg, QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) if ret == QtWidgets.QMessageBox.Yes: noaa_support.open_system_noaa_support_folder() return installed = noaa_support.exec_system_batch() if installed: msg = "Follow the instruction in the windows shell!" # noinspection PyCallByClass,PyArgumentList QtWidgets.QMessageBox.information(self, "Windows shell", msg, QtWidgets.QMessageBox.Ok) return else: msg = "Unable to install the support files.\n" \ "Try to manually run as administrator the batch file at: %s\n\n" \ % (noaa_support.system_batch_file()) # noinspection PyCallByClass,PyArgumentList QtWidgets.QMessageBox.critical(self, "Error", msg, QtWidgets.QMessageBox.Ok) noaa_support.open_system_noaa_support_folder() return else: installed = noaa_support.exec_system_batch() if installed: msg = "Success!" # noinspection PyCallByClass,PyArgumentList QtWidgets.QMessageBox.information(self, "Installation done!", msg, QtWidgets.QMessageBox.Ok) return else: msg = "Unable to install the support files.\n" \ "Try to manually run as administrator the batch file at: %s\n\n" \ % (noaa_support.system_batch_file()) # noinspection PyCallByClass,PyArgumentList QtWidgets.QMessageBox.critical(self, "Error", msg, QtWidgets.QMessageBox.Ok) noaa_support.open_system_noaa_support_folder() return