def test_init(self):

        noaa_support = NOAASupport(lib_info=LibInfo(), app_info=AppInfo())

        self.assertTrue("v" in noaa_support.v_version())
        self.assertTrue(os.path.exists(noaa_support.internal_zip_path()))
        self.assertTrue(noaa_support.internal_zip_path_exists())
Exemple #2
0
    def noaa_support_unzip(self):
        logger.debug("unzipping NOAA Support Files")

        noaa_support = NOAASupport(app_info=self._ai,
                                   lib_info=self._li,
                                   progress=QtProgress(parent=self))

        if noaa_support.local_noaa_support_folder_present():
            msg = "The support folder was already unzipped:\n" \
                  "- %s\n\n" \
                  "Do you want to force to re-unzip it? If no, go to step #2." \
                  % noaa_support.local_noaa_support_folder()
            # noinspection PyCallByClass,PyArgumentList
            ret = QtWidgets.QMessageBox.information(
                self, "Unzip folder", msg,
                QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
            if ret == QtWidgets.QMessageBox.No:
                return

        unzipped = False

        if noaa_support.internal_zip_path_exists():
            internal_zip_path = noaa_support.internal_zip_path()
            logger.debug("internal zip: %s" % internal_zip_path)

            success = noaa_support.unzip_internal_zip()
            logger.debug("installed internal zip: %s" % success)
            if success:
                unzipped = True

        if not unzipped:
            success = noaa_support.download_from_noaa()
            logger.debug("download from noaa: %s" % success)
            if success:
                unzipped = True

        if not unzipped:
            success = noaa_support.download_from_unh()
            logger.debug("download from unh: %s" % success)
            if success:
                unzipped = True

        # noinspection PyArgumentList
        if unzipped and noaa_support.local_noaa_support_folder_present():
            msg = "Success! Go to step #2."
            # noinspection PyCallByClass,PyArgumentList
            QtWidgets.QMessageBox.information(self, "Unzip done!", msg,
                                              QtWidgets.QMessageBox.Ok)
            return

        else:
            msg = "Unable to unzip the archive. Do you have a working Internet connection?"
            # noinspection PyCallByClass,PyArgumentList
            QtWidgets.QMessageBox.critical(self, "Error", msg,
                                           QtWidgets.QMessageBox.Ok)
            return
Exemple #3
0
    def noaa_support_copy(self):
        logger.debug("copying NOAA Support Files")

        noaa_support = NOAASupport(app_info=self._ai,
                                   lib_info=self._li,
                                   progress=QtProgress(parent=self))

        if not noaa_support.local_noaa_support_folder_present():
            msg = "The support folder is not present!\n" \
                  "Did you unzip it? Go to step #1."
            # noinspection PyCallByClass,PyArgumentList
            QtWidgets.QMessageBox.information(self, "Copy folder", msg,
                                              QtWidgets.QMessageBox.Ok)
            return

        if noaa_support.system_noaa_support_folder_present():
            msg = "The support folder was already copied:\n" \
                  "- %s\n\n" \
                  "Do you want to force the re-copy? If no, go to step #3." % noaa_support.system_noaa_support_folder()
            # noinspection PyCallByClass,PyArgumentList
            ret = QtWidgets.QMessageBox.information(
                self, "Copy folder", msg,
                QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
            if ret == QtWidgets.QMessageBox.No:
                return
            noaa_support.delete_system_noaa_support_files()

        copied = noaa_support.copy_local_to_system()
        logger.info(copied)
        if copied and noaa_support.system_noaa_support_folder_present():
            msg = "Success! Go to step #3."
            # noinspection PyCallByClass,PyArgumentList
            QtWidgets.QMessageBox.information(self, "Copy done!", msg,
                                              QtWidgets.QMessageBox.Ok)
            return

        else:
            msg = "Unable to copy the folder:\n" \
                  "- %s\n" \
                  "to:\n" \
                  "- %s\n" \
                  "Try to manually do the copy or re-run QC Tools as administrator." \
                  % (noaa_support.local_noaa_support_folder(), noaa_support.caris_root)
            # noinspection PyCallByClass,PyArgumentList
            QtWidgets.QMessageBox.critical(self, "Error", msg,
                                           QtWidgets.QMessageBox.Ok)
            return
Exemple #4
0
from hyo2.abc.app.app_info import AppInfo
from hyo2.abc.lib.logging import set_logging

logger = logging.getLogger(__name__)
set_logging(ns_list=["hyo2.abc"])

use_setup = 0  # 0: internal, 1: NOAA, 2: CCOM
delete_local_folder = False
copy_files = True

QtWidgets.QApplication([])
w = QtWidgets.QWidget()
w.show()

noaa_support = NOAASupport(lib_info=LibInfo(),
                           app_info=AppInfo(),
                           progress=QtProgress(parent=w))

if use_setup == 0:

    if noaa_support.internal_zip_path_exists():
        internal_zip_path = noaa_support.internal_zip_path()
        logger.debug("internal zip: %s" % internal_zip_path)

        success = noaa_support.unzip_internal_zip()
        logger.debug("installed internal zip: %s" % success)
        if not success:
            exit(-1)

elif use_setup == 1:  # 5.8 is now 7z, thus this fails
Exemple #5
0
    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