def start_indi_dialog(self):
        """
        The "configure" button has been clicked for the INDI telescope interface:
        Open the INDI dialog.

        :return: -
        """

        try:
            # PyIndi is only available on Linux and MacOS. On Windows systems, do nothing.
            import PyIndi
        except ImportError:
            Miscellaneous.show_detailed_error_message("The INDI interface does not seem to work.",
                                                      "Most likely PyIndi is not installed on "
                                                      "this computer.\n\nIf this is a Windows "
                                                      "system, "
                                                      "there might be an ASCOM client available. "
                                                      "In this case, try to use 'ASCOM' instead "
                                                      "of 'INDI'.")
            return

        from indi_configuration_editor import IndiConfigurationEditor

        self.indieditor = IndiConfigurationEditor(self.c, self.new_web_browser_path,
                                                  self.new_indi_server_url,
                                                  self.new_indi_pulse_guide_speed_index,
                                                  self.new_indi_guiding_interval,
                                                  self.new_indi_wait_interval,
                                                  self.new_indi_telescope_lookup_precision)
        # Start the GUI.
        self.indieditor.exec_()

        # Remember that the INDIConfigurationEditor was invoked.
        self.indieditor_called = True
        # Check if the configuration has changed.
        if self.indieditor.configuration_changed:
            # Mark the configuration object as changed.
            self.configuration_changed = True
            # Copy back the current gui values.
            self.new_web_browser_path = str(self.indieditor.input_web_browser_path.text())
            self.new_indi_server_url = str(self.indieditor.input_indi_server_url.text())
            self.new_indi_pulse_guide_speed_index = str(
                self.indieditor.pulse_guide_speed_chooser.currentIndex())
            self.new_indi_guiding_interval = str(self.indieditor.input_guiding_interval.text())
            self.new_indi_wait_interval = str(self.indieditor.input_wait_interval.text())
            self.new_indi_telescope_lookup_precision = str(
                self.indieditor.input_telescope_lookup_precision.text())
        if self.indieditor.telescope_changed:
            # Mark the telescope driver as changed.
            self.telescope_changed = True
    def start_ascom_dialog(self):
        """
        The "configure" button has been clicked for the ASCOM telescope interface:
        Open the ASCOM dialog.

        :return: -
        """

        try:
            # ASCON is only available on Windows. On Linux systems, do nothing.
            from ascom_configuration_editor import AscomConfigurationEditor
        except ImportError:
            Miscellaneous.show_detailed_error_message("The ASCOM interface does not seem to work.",
                                                      "Most likely the ASCOM platform is not "
                                                      "installed on this computer.\n\nIf this is "
                                                      "a Linux system, "
                                                      "there might be an INDI client available. "
                                                      "In this case, try to use 'INDI' instead of "
                                                      "'ASCOM'.")
            return

        self.ascomeditor = AscomConfigurationEditor(self.c, self.new_ascom_driver_name,
                                                    self.new_ascom_guiding_interval,
                                                    self.new_ascom_wait_interval,
                                                    self.new_ascom_pulse_guide_speed_ra,
                                                    self.new_ascom_pulse_guide_speed_de,
                                                    self.new_ascom_telescope_lookup_precision)
        # Start the GUI.
        self.ascomeditor.exec_()

        # Remember that the AscomConfigurationEditor was invoked.
        self.ascomeditor_called = True
        # Check if the configuration has changed.
        if self.ascomeditor.configuration_changed:
            # Mark the configuration object as changed.
            self.configuration_changed = True
            # Copy back the current gui values.
            self.new_ascom_driver_name = self.ascomeditor.new_driver_name
            self.new_ascom_guiding_interval = str(self.ascomeditor.input_guiding_interval.text())
            self.new_ascom_wait_interval = str(self.ascomeditor.input_wait_interval.text())
            self.new_ascom_pulse_guide_speed_ra = str(
                self.ascomeditor.input_pulse_guide_speed_ra.text())
            self.new_ascom_pulse_guide_speed_de = str(
                self.ascomeditor.input_pulse_guide_speed_de.text())
            self.new_ascom_telescope_lookup_precision = str(
                self.ascomeditor.input_telescope_lookup_precision.text())
        if self.ascomeditor.telescope_changed:
            # Mark the telescope driver as changed.
            self.telescope_changed = True
Esempio n. 3
0
 def open_ascom_chooser(self):
     try:
         x = win32com.client.Dispatch("ASCOM.Utilities.Chooser")
         x.DeviceType = 'Telescope'
         driver_name = x.Choose(self.new_driver_name)
         if driver_name != "":
             self.new_driver_name = driver_name
     except:
         if self.c.protocol_level > 0:
             Miscellaneous.protocol("Unable to access the ASCOM telescope chooser. Please check"
                                    " the ASCOM platform installation.")
         Miscellaneous.show_detailed_error_message("Unable to access the ASCOM telescope "
                                                   "chooser", "Is the ASCOM Platform "
                                                              "installed on this "
                                                              "computer? Please check the "
                                                              "installation.")
    def open_indi_manager(self):
        """
        Open the INDI manager in a web browser to configure the hardware drivers. First,
        the 'indi-web' process must be started on the system where the INDI server is running.
        If this is on localhost, MoonPanoramaMaker can test if the process is running, and,
        if not, start it. If the INDI server runs on a remote system, it is the
        user's responsibility to start the process there.

        :return: -
        """

        # Check if the given URL of the INDI server is valid.
        server_url = str(self.input_indi_server_url.text())
        if Miscellaneous.testipaddress(server_url):
            if server_url == "localhost" or server_url == "127.0.0.1":
                # The server is running locally: Check if 'indi-web' is running. If not, start it.
                indi_web_is_running = len(
                    os.popen('pgrep indi-web').read()) > 0
                if not indi_web_is_running:
                    os.system('indi-web &')
                    # Check if 'indi-web' appears in the list of active processes.
                    success = False
                    for trial in range(5):
                        time.sleep(self.c.polling_interval)
                        if len(os.popen('pgrep indi-web').read()) > 0:
                            success = True
                            break
                    if not success:
                        # The 'indi-web' process could not be started. Issue an error message.
                        if self.c.protocol_level > 0:
                            Miscellaneous.protocol(
                                "Unable to start the 'indi-web' process locally. Please "
                                "check the INDI installation.")
                        return

            else:
                # If the server is on a remote system, MoonPanoramaMaker cannot start 'indi-web'
                # there. Ask the user for confirmation that 'indi-web' is started.
                msg = "Make sure that 'indi-web' is started on the system where the INDI server " \
                      "is running. To start the 'indi-web' process, open a terminal on the remote" \
                      " system and enter 'indi-web &'. Please confirm that 'indi-web' is running."

                reply = QtWidgets.QMessageBox.question(
                    self, 'Message', msg,
                    QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
                    QtWidgets.QMessageBox.No)
                # Negative reply: Issue an error message and exit.
                if reply != QtWidgets.QMessageBox.Yes:
                    Miscellaneous.show_detailed_error_message(
                        "The INDI manager cannot be opened.",
                        "MoonPanoramaMaker can only handle the INDI server configuration if the "
                        "'indi-web' process is started on the server system. Alternatively, "
                        "you may configure the INDI server outside MoonPanoramaMaker using some "
                        "other program.")
                    return

            # 'indi-web' is running. Check if the web browser path exists,
            #  and open the URL in the standard web browser.
            if not os.path.exists(str(self.input_web_browser_path.text())):
                Miscellaneous.show_detailed_error_message(
                    "The standard web browser cannot be launched.",
                    "The parameter 'Standard web browser' is wrong. Please make sure that it "
                    "points to a web browser executable, e.g. '/usr/bin/firefox'."
                )
                return
            try:
                import subprocess
                subprocess.Popen([
                    str(self.input_web_browser_path.text()),
                    "http://" + server_url + ":8624"
                ])
                self.configuration_changed = True
                self.telescope_changed = True
            except:
                if self.c.protocol_level > 0:
                    Miscellaneous.show_detailed_error_message(
                        "Unable to access the indi-web manager.",
                        "Please check the standard web browser path and the INDI installation."
                    )

        else:
            # The given URL is invalid. Issue an error message and exit.
            Miscellaneous.show_detailed_error_message(
                "Invalid URL entered.",
                "The URL of the INDI server is not correct. "
                "It must be eigher 'localhost' or the IP "
                "number "
                "of the system where the INDI "
                "server is executed. (e.g. '192.168.0.2') ")