def waiting_the_stop(self): self.discord_status_updating_thread.join() self.custom_signal.threadStopped.emit() self.core.stop_thread = False logging.info("Stopped animated status.")
def restart(self): """Restarts the program.""" logging.info("Forced restart. Restarting...") self.core.config_save() self.tray_icon.hide() scr = sys.executable os.execl(scr, scr, *sys.argv)
def stop(self): """Stop animated status.""" logging.info("Stopping animated status...") self.core.stop_thread = True self.stop_btn.setEnabled(False) self.run_stop_animated_status.setEnabled(False) self.info_screen.setText(self.lang_manager.get_string("stopping")) wait_the_stop = Thread(target=self.waiting_the_stop, daemon=True) wait_the_stop.start()
def run(self): """Run animated status.""" logging.info("Starting animated status...") if self.core.config["frames"] == []: self.show() logging.error("Failed to run animated status: Frame list is empty.") error = QMessageBox() error.setWindowTitle(self.lang_manager.get_string("error")) error.setWindowIcon(self.icon) error.setText(self.lang_manager.get_string("frame_list_empty")) error.setIcon(error.Warning) error.exec_() elif self.core.config["token"] == "": self.show() logging.error("Failed to run animated status: Token is empty.") error = QMessageBox() error.setWindowTitle(self.lang_manager.get_string("error")) error.setWindowIcon(self.icon) error.setText(self.lang_manager.get_string("input_token")) error.setIcon(error.Warning) error.exec_() if self.core.config["hide_token_input"]: error = QMessageBox() error.setWindowTitle(self.lang_manager.get_string("error")) error.setWindowIcon(self.icon) error.setText(self.lang_manager.get_string("unhide_token")) error.setIcon(error.Warning) error.exec_() else: for char in self.core.config["token"]: if char not in ascii_chars: logging.error("Failed to run animated status: Forbidden chars in token.") error = QMessageBox() error.setWindowTitle(self.lang_manager.get_string("error")) error.setWindowIcon(self.icon) error.setText(self.lang_manager.get_string("token_invalid")) error.setIcon(error.Warning) error.exec_() break else: self.run_btn.setEnabled(False) self.stop_btn.setEnabled(True) self.run_stop_animated_status.disconnect() self.run_stop_animated_status.setText(self.lang_manager.get_string("stop")) self.run_stop_animated_status.triggered.connect(self.stop) self.discord_status_updating_thread = Thread(target=self.core.run_animated_status, daemon=True) self.discord_status_updating_thread.start() logging.info("Started animated status.")
def entry(): """Application entry point.""" logging.basicConfig(filename="last.log", level=logging.INFO, format="%(asctime)-15s | %(levelname)s | %(message)s") logging.info("--- LOG START ---") win = QApplication(sys.argv) apply_style(win) App() code = win.exec_() logging.info("Program exit with code %d.", code) if code != 0: logging.warning( "Program exit code was not 0. This means something went wrong while executing the program." ) logging.info("--- LOG END ---") sys.exit(code)