Example #1
0
        public (Dictionary <string, TentacleModule>, PackageDescription, Uri, bool?, string, string) GetPackageInLists(string componentName, string componentVersion = "")
        {
            if (TentacleUtil.HasRequiredPackage(DefaultPackage, componentName, componentVersion) == true)
            {
                var packageDescription  = DefaultPackage.PackageDescription;
                var packageLocalisation = packageDescription.Localisation;
                var isUrl       = packageDescription.IsUrl;
                var packageName = packageDescription.Name;

                return(DefaultPackage.ListPuneHedgehog, packageDescription, packageLocalisation, isUrl, TentaclesManagerVars.EVALUATOR_DEFAULT_FOLDER, packageName);
            }
            else
            {
                foreach (var advancedPackage in AdvancedPackageList)
                {
                    if (TentacleUtil.HasRequiredPackage((TentaclesListJson)advancedPackage, componentName, componentVersion) == true)
                    {
                        var packageDescription  = ((TentaclesListJson)advancedPackage).PackageDescription;
                        var packageLocalisation = packageDescription.Localisation;
                        var isUrl       = packageDescription.IsUrl;
                        var packageName = packageDescription.Name;

                        return(((TentaclesListJson)advancedPackage).ListPuneHedgehog, packageDescription, packageLocalisation, isUrl, TentaclesManagerVars.EVALUATOR_DEFAULT_FOLDER, packageName);
                    }
                }
            }

            return(null, null, null, null, null, null);
        }
Example #2
0
        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 {
Example #3
0
        private int InstallParser(IList <string> commands, bool commandAll = false, bool force = false)
        {
            bool shouldInstall = true;

            // first ensure the current tentacles architecture is setup correctly
            if (TentacleUtil.CreateMissingTentaclesArch() == true && force == false)
            {
                Debug.WriteLine(1);
            }

            int nbActions = 0;

            if (shouldInstall == true)
            {
                // then process installations
                if (commandAll == true)
                {
                    TentaclePackageManager.SetMaxSteps(GetPackageCount());
                    TentaclePackageManager.TryActionOnTentaclesPackage(TentaclesManagerVars.TentacleManagerActions.INSTALL, DefaultPackage, TentaclesManagerVars.EVALUATOR_DEFAULT_FOLDER);

                    foreach (var package in AdvancedPackageList)
                    {
                        TentaclePackageManager.TryActionOnTentaclesPackage(TentaclesManagerVars.TentacleManagerActions.INSTALL, (TentaclesListJson)package, TentaclesManagerVars.EVALUATOR_ADVANCED_FOLDER);
                    }

                    nbActions = GetPackageCount();
                }
                else
                {
                    Debug.WriteLine(1);
                }

                TentaclePackageManager.UpdateEvaluatorConfigFile();
                TentaclePackageManager.UpdateTradingConfigFile();

                return(nbActions);
            }
            else
            {
                return(0);
            }
        }
Example #4
0
        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");
            }
        }
Example #5
0
 public bool TentaclesArchExists()
 {
     return(TentacleUtil.TentaclesArchExists());
 }