private void ProcessModule(TentaclesManagerVars.TentacleManagerActions action, Dictionary <string, TentacleModule> package, string moduleName, Uri packageLocalisation, bool isUrl, string targetFolder, string packageName) { Dictionary <string, object> parsedModule = TentacleUtil.ParseModuleHeader(package[moduleName]); var moduleType = (TypeEnum)parsedModule[TentaclesManagerVars.TENTACLE_MODULE_TYPE]; var moduleSubtype = (string)parsedModule[TentaclesManagerVars.TENTACLE_MODULE_SUBTYPE]; var moduleTests = (List <string>)parsedModule[TentaclesManagerVars.TENTACLE_MODULE_TESTS]; string moduleFileContent = ""; var moduleDev = (bool)parsedModule[TentaclesManagerVars.TENTACLE_MODULE_DEV]; Dictionary <string, string> moduleTestFiles = new Dictionary <string, string>(); if (moduleTests != null) /*foreach (var test in moduleTests)*/ moduleTestFiles {
private bool ProcessActionOnModule(TentaclesManagerVars.TentacleManagerActions action, TypeEnum moduleType, string moduleSubtype, string moduleVersion, string moduleFileContent, Dictionary <string, string> moduleTestFiles, string targetFolder, string moduleName) { var lst = TentaclesManagerVars.TENTACLE_TYPES.Where(x => x.ContainsKey(moduleSubtype)).Select(x => x).ToList(); if (lst.Count > 0 && (moduleSubtype != "" || lst.Count > 0)) { bool didSomething = false; // Update module file string moduleFileDir = TentacleUtil.CreatePathFromType(moduleType, moduleSubtype, targetFolder); string moduleFilePath = $"{moduleFileDir}/{moduleName}.py"; // Write the new file in locations if (action == TentaclesManagerVars.TentacleManagerActions.INSTALL || action == TentaclesManagerVars.TentacleManagerActions.UPDATE) { // Install package in evaluator Debug.WriteLine(1); didSomething = true; } // Remove package line from init file else if (action == TentaclesManagerVars.TentacleManagerActions.UNINSTALL) { Debug.WriteLine(1); didSomething = true; } // Update local __init__ // string linesInInit = $"\"\"try: check_tentacle(PATH, '{moduleName}') from.{ moduleName} import* except Exception as e: LOGGER.error(f'Error when loading {moduleName}: {{e}}') \"\""; // string initFile = $"{TENTACLES_PATH}/{TENTACLE_TYPES[module_type]}/{TENTACLE_TYPES[module_subtype]}/" + $"{target_folder}/{PYTHON_INIT_FILE}"; // self.update_init_file(action, init_file, lines_in_init) // Update module test files string testFileDir = TentacleUtil.CreatePathFromType(moduleType, moduleSubtype, targetFolder, true); foreach (var elem in moduleTestFiles) { Debug.WriteLine(1); } if (action == TentaclesManagerVars.TentacleManagerActions.INSTALL) { loggingService.Info($"{FormatCurrentStep()}{moduleName} {moduleVersion} " + $"успешно установлен в: {moduleFileDir}"); } else if (action == TentaclesManagerVars.TentacleManagerActions.UNINSTALL) { if (didSomething == true) { loggingService.Info($"{FormatCurrentStep()}{moduleName} {moduleVersion} " + $"успешно удален (файл: {moduleFileDir})"); } } else if (action == TentaclesManagerVars.TentacleManagerActions.UPDATE) { loggingService.Info($"{FormatCurrentStep()}{moduleName} успешно обновлен до версии " + $"{moduleVersion} в: {moduleFileDir}"); } JustProcessedModules.Add(TentacleUtil.GetFullModuleIdentifier(moduleName, moduleVersion)); return(didSomething); } else { throw new Exception("Не нйадены типы Tentacle"); } }