def _start_session(self, is_retry: bool = False): """ Stars session :param is_retry: is this a retry ? :type is_retry: bool """ try: self._controller.start_session() if is_retry: message_box("Session started", "Session successfully started after retry") except CriticalFolderMissing as folder_missing: text = folder_missing.details text += "\n\n Would you like to open the preferences box ?" if question(folder_missing.message, text) and self._open_preferences(): self._start_session(is_retry=True) except SessionError as session_error: error_box(session_error.message, str(session_error.details) + "\n\nSession start aborted")
def _start_www(self): """Starts web server""" self.web_dir = config.get_work_folder_path() ip_address = MainWindow.get_ip() port_number = config.get_www_server_port_number() try: self.thread = StoppableServerThread(self.web_dir) self.thread.start() # Server is now started and listens on specified port on *all* available interfaces. # We get the machine ip address and warn user if detected ip is loopback (127.0.0.1) # since in this case, the web server won't be reachable by any other machine if ip_address == "127.0.0.1": log_function = _LOGGER.warning title = "Web server access is limited" message = "Web server IP address is 127.0.0.1.\n\nServer won't be reachable by other " \ "machines. Please check your network connection" warning_box(title, message) else: log_function = _LOGGER.info log_function( f"Web server started. http://{ip_address}:{port_number}") self._ui.action_prefs.setEnabled(False) except OSError: title = "Could not start web server" message = f"The web server needs to listen on port n°{port_number} but this port is already in use.\n\n" message += "Please change web server port number in your preferences " _LOGGER.error(title) error_box(title, message) self._stop_www() self._ui.cbWww.setChecked(False)
def _save_config(): try: config.save() except CouldNotSaveConfig as save_error: error_box( save_error.message, f"Your settings could not be saved\n\nDetails : {save_error.details}" )
def _start_www(self): """Starts web server""" try: self._controller.start_www() if DYNAMIC_DATA.web_server_ip == "127.0.0.1": title = "Web server access is limited" message = "Web server IP address is 127.0.0.1.\n\nServer won't be reachable by other " \ "machines. Please check your network connection" warning_box(title, message) except WebServerStartFailure as start_failure: error_box(start_failure.message, start_failure.details)
def save(): """ Saves settings to disk. :except os_error: Saving could not be done """ try: with open(_CONFIG_FILE_PATH, "w") as config_file: _CONFIG_PARSER.write(config_file) _LOGGER.info("User configuration saved") except OSError as os_error: _LOGGER.error("Could not save settings. Error : %s", os_error) dialogs.error_box( "Settings not saved", f"Your settings could not be saved\n\nDetails : {os_error}")
def main(): """app launcher""" import sys app = QApplication(sys.argv) try: pass except ValueError as value_error: error_box("Config file is invalid", str(value_error)) print(f"***** ERROR : user config file is invalid : {value_error}") sys.exit(1) _LOGGER.info( f"Starting Astro Live Stacker v{VERSION} in {os.path.dirname(os.path.realpath(__file__))}" ) _LOGGER.debug("Building and showing main window") window = MainWindow() (x, y, width, height) = config.get_window_geometry() window.setGeometry(x, y, width, height) window.show() app_return_code = app.exec() _LOGGER.info( f"Astro Live Stacker terminated with return code = {app_return_code}") sys.exit(app_return_code)
def cb_play(self): """Qt slot for mouse clicks on the 'play' button""" # check existence of work and scan folders scan_folder_path = config.get_scan_folder_path() if not os.path.exists(scan_folder_path) or not os.path.isdir( scan_folder_path): if question( "Scan folder issue", f"Your configured scan folder '{scan_folder_path}' is missing.\n" f"Do you want to open preferences screen ?"): self.cb_prefs() else: return work_folder_path = config.get_work_folder_path() if not os.path.exists(work_folder_path) or not os.path.isdir( work_folder_path): if question( "Work folder issue", f"Your configured work folder '{work_folder_path}' is missing.\n" f"Do you want to open preferences screen ?"): self.cb_prefs() else: return if self.image_ref_save.status == "stop": self._ui.white_slider.setEnabled(False) self._ui.black_slider.setEnabled(False) self._ui.contrast_slider.setEnabled(False) self._ui.brightness_slider.setEnabled(False) self._ui.R_slider.setEnabled(False) self._ui.G_slider.setEnabled(False) self._ui.B_slider.setEnabled(False) self._ui.pb_apply_value.setEnabled(False) self._ui.cbAlign.setEnabled(False) self._ui.cmMode.setEnabled(False) self._ui.image_stack.setPixmap(QPixmap(":/icons/dslr-camera.svg")) self.counter = 0 self._ui.cnt.setText(str(self.counter)) # Print scan folder self._ui.log.append( _("Scan folder : ") + config.get_scan_folder_path()) # Print work folder self._ui.log.append( _("Work folder : ") + config.get_work_folder_path()) # check align if self._ui.cbAlign.isChecked(): self.align = True # Print live method if self.align: self._ui.log.append( _("Play with alignement type: ") + self._ui.cmMode.currentText()) else: self._ui.log.append(_("Play with NO alignement")) self.file_watcher = WatchOutForFileCreations( config.get_scan_folder_path(), config.get_work_folder_path(), self.align, self._ui.cbKeep.isChecked(), self._ui.cmMode.currentText(), self._ui.log, self._ui.white_slider, self._ui.black_slider, self._ui.contrast_slider, self._ui.brightness_slider, self._ui.R_slider, self._ui.G_slider, self._ui.B_slider, self._ui.pb_apply_value, self.image_ref_save, self._ui.cbSCNR, self._ui.cmSCNR, self._ui.SCNR_Slider, self._ui.cbWavelets, self._ui.cBoxWaveType, self._ui.cbLuminanceWavelet, self._ui.wavelet_1_label, self._ui.wavelet_2_label, self._ui.wavelet_3_label, self._ui.wavelet_4_label, self._ui.wavelet_5_label) try: self._setup_work_folder() except OSError as os_error: title = "Work folder could not be prepared" message = f"Details : {os_error}" error_box(title, message) _LOGGER.error(f"{title} : {os_error}") self.cb_stop() return self.file_watcher.start() self.file_watcher.print_image.connect( lambda: self.update_image(config.get_work_folder_path())) self.image_ref_save.status = "play" self.image_ref_save.image = None self.image_ref_save.stack_image = None # deactivate play button self._ui.pbPlay.setEnabled(False) self._ui.pbReset.setEnabled(False) # activate stop button self._ui.pbStop.setEnabled(True) # activate pause button self._ui.pbPause.setEnabled(True) self._ui.action_prefs.setEnabled(False)