def delete_costume(self, id): if fm.exists(CONST_COSTUME_DIR, CONST_COSTUME_NAME_PREFIX + '{}'.format(id)): fm.delete_file(CONST_COSTUME_DIR, CONST_COSTUME_NAME_PREFIX + '{}'.format(id)) log_manager.log("Costume deleted", send_msg=True) else: log_manager.log("Costume not found") return
def save_costume(self): if self.id == -1: log_manager.warning("Not saving costume, not initialised") return jstring = fm.encode_to_json(self) fm.write_file(CONST_COSTUME_DIR, CONST_COSTUME_NAME_PREFIX + "{}".format(self.id), jstring) log_manager.log("costume save", send_msg=True) return
def terminate_script(self, costume_part: CostumePart): if not self.__initialised: return None thread_id = self.running_costume_parts[costume_part.id] if g_tm.terminate_thread(thread_id): self.running_costume_parts.pop(costume_part.id) log_manager.log("script stopped", send_msg=True) else: log_manager.error( "An error occurred, couldn't stop script. If the program behaves in unexpected ways please restart", send_msg=True) return
def import_settings(self): jstring = fm.open_file(CONST_CONFIG_DIR, CONST_CONFIG_FILENAME) load = fm.decode_json(jstring) if not load: self.save_settings() log_manager.log("Created settings file") return True if (load.active_library == ""): log_manager.error( "Couldn't import ignite configs, setting defaults") return False log_manager.log("Ignite configs imported") return True
def load_costume(self, id): if not fm.exists(CONST_COSTUME_DIR, id): log_manager.error("Couldn't find costume, try again", send_msg=True) return jstring = fm.open_file(CONST_COSTUME_DIR, id) obj = fm.decode_json(jstring) if (obj is None): log_manager.error("Couldn't load costume, try again", send_msg=True) return self.__current_costume = obj log_manager.log("Costume loaded", send_msg=True) return
def terminate_all_scripts(self): if not self.__initialised: return None terminated_thread_ids = list() if g_tm.terminate_all_termination_tasks(terminated_thread_ids): log_manager.log("scripts stopped", send_msg=True) #self.__cleanup_active_costume_parts() else: log_manager.error( "couldn't stop all scripts, please restart program", send_msg=True) # remove terminated threads from running_costume_parts running_parts = { key: val for key, val in self.running_costume_parts.items() if val not in terminated_thread_ids } self.running_costume_parts = running_parts return