def install(self):
try:
Repo.clone_from(self.url, self.app.config['SKILL_FOLDER'] + self.name)
json.path = self.app.config['SKILL_FOLDER'] + self.name + "/package.json"
data = json.decode_path()
self.install_dep(data)
self.install_pip(data)
skill = get_skill_function(self.app.config['SKILL_FOLDER'], self.name)
if (hasattr(skill, 'create_skill') and callable(skill.create_skill)):
Module = skill.create_skill()
if (hasattr(Module, 'install') and callable(Module.install)):
try:
Module.install()
except Exception as e:
logger.error('Install Skill error for ' + self.name + ' : ' + str(e))
if (hasattr(Module, 'get_blueprint') and callable(Module.get_blueprint)):
self.app.register_blueprint(Module.get_blueprint())
if data['navbar'] == 'True':
navbar.folder = self.name
navbar.set_plugin_navbar()
os.system('cd ' + self.app.config['SKILL_FOLDER'] + self.name + ' && make compilelang')
bot = kernel.set()
kernel.train(bot)
logger.info('Installation done with success')
return json.encode({"status":"success"})
except Exception as e:
logger.error('Installation error : ' + str(e))
return json.encode({"status":"error"})
评论列表
文章目录