def install(self): """ Module installation method. """ # first, we clone the repo self._clone_repo(path=self.tmp_path, git_url=self.git_url) # check the content of the cloned repo if self.is_repo_ok(dna_file_path=self.dna_file_path, install_file_path=self.install_file_path): # Load the dna.yml file self.dna = DnaLoader(self.dna_file_path).get_dna() if self.dna is not None: logger.debug("[ResourcesManager] DNA file content: " + str(self.dna)) if self.is_settings_ok(resources=self.settings.resources, dna=self.dna): # the dna file is ok, check the supported version if self._check_supported_version( current_version=self.settings.intelora_version, supported_versions=self.dna. intelora_supported_version): # Let's find the target folder depending the type module_type = self.dna.module_type.lower() target_folder = self._get_target_folder( resources=self.settings.resources, module_type=module_type) if target_folder is not None: # let's move the tmp folder in the right folder and get a new path for the module module_name = self.dna.name.lower() target_path = self._rename_temp_folder( name=self.dna.name.lower(), target_folder=target_folder, tmp_path=self.tmp_path) # if the target_path exists, then run the install file within the new repository if target_path is not None: self.install_file_path = target_path + os.sep + INSTALL_FILE_NAME if self.run_ansible_playbook_module( install_file_path=self. install_file_path): Utils.print_success( "Module: %s installed" % module_name) else: Utils.print_danger( "Module: %s not installed" % module_name) else: logger.debug( "[ResourcesManager] installation cancelled, deleting temp repo %s" % str(self.tmp_path)) shutil.rmtree(self.tmp_path)
def uninstall(self, neuron_name=None, tts_name=None, stt_name=None, trigger_name=None, signal_name=None): """ Uninstall a community resource """ target_path_to_delete = None module_name = "" if neuron_name is not None: target_path_to_delete = self._get_target_folder( resources=self.settings.resources, module_type=TYPE_NEURON) module_name = neuron_name if tts_name is not None: target_path_to_delete = self._get_target_folder( resources=self.settings.resources, module_type=TYPE_TTS) module_name = tts_name if stt_name is not None: target_path_to_delete = self._get_target_folder( resources=self.settings.resources, module_type=TYPE_STT) module_name = stt_name if trigger_name is not None: target_path_to_delete = self._get_target_folder( resources=self.settings.resources, module_type=TYPE_TRIGGER) module_name = trigger_name if signal_name is not None: target_path_to_delete = self._get_target_folder( resources=self.settings.resources, module_type=TYPE_SIGNAL) module_name = signal_name if target_path_to_delete is not None: try: shutil.rmtree(target_path_to_delete + os.sep + module_name.lower()) Utils.print_success("Module %s deleted" % module_name.lower()) except shutil.Error: Utils.print_warning( "The module %s doest not exist in the path %s" % (module_name.lower(), target_path_to_delete)) except OSError: Utils.print_warning( "The module %s doest not exist in the path %s" % (module_name.lower(), target_path_to_delete))