def save_template(self, path, defaults=False): if path.rfind("/") == -1: filename = "default" path = "." else: filename = path[path.rfind("/") + 1:len(path)] path = path[0:path.rfind("/")] self.template = TemplateMgr() try: self.template.open(filename, path) self.configuration.save(self.template, defaults) self.template.save() except Exception as e: self.show_error_dialog("Hob Exception - %s" % (str(e))) self.reset() finally: self.template.destroy() self.template = None
def load_template(self, path): if not os.path.isfile(path): return None self.template = TemplateMgr() try: self.template.load(path) self.configuration.load(self.template) except Exception as e: self.show_error_dialog("Hob Exception - %s" % (str(e))) self.reset() finally: self.template.destroy() self.template = None for layer in self.configuration.layers: if not os.path.exists(layer + '/conf/layer.conf'): return False self.save_defaults() # remember layers and settings self.update_config_async() return True