Example #1
0
    public static ConfigSet ToEffectiveConfig(this WorkspaceConfig root)
    {
        return(new ConfigSet(root.path, GetEffectiveConfig(root).ToDictionary(x => x.Id, x => x)));

        IEnumerable <IRunnableConfig> GetEffectiveConfig(WorkspaceConfig node)
        {
            if (node == null)
            {
                return new IRunnableConfig[] { }
            }
            ;

            var configs = node.Elements <IRunnableConfig>()
                          .GroupBy(x => x.Id)
                          .Select(x => x.First())
                          .ToArray();

            if (node.import == null)
            {
                return(configs);
            }

            var nested = (from w in node.import select GetEffectiveConfig(w)).SelectMany(w => w).ToArray();

            return(configs.Concat(nested.Except(configs)));
        }
    }
}
Example #2
0
 public override void LoadFromWorkspaceConfig(WorkspaceConfig config, ProjectConfig projectConfig)
 {
     if (projectConfig != null)
     {
         UpdateCacheModeCheckboxes(projectConfig.AssetCacheMode);
     }
 }
Example #3
0
        public async Task Initialize()
        {
            if (!Directory.Exists(TestCaseStoreRoot))
            {
                Directory.CreateDirectory(TestCaseStoreRoot);
            }
            if (!Directory.Exists(SubmissionStoreRoot))
            {
                Directory.CreateDirectory(SubmissionStoreRoot);
            }

            List <ProgrammingLanguage> langs = new List <ProgrammingLanguage>();

            foreach (KeyValuePair <ProgrammingLanguage, JudgerLangConfig> v in Judger.DefaultLangConfigs)
            {
                langs.Add(v.Key);
            }
            WorkspaceConfig config = new WorkspaceConfig
            {
                SupportLanguages = langs
            };

            _context.WorkspaceInfos.RemoveRange(_context.WorkspaceInfos.ToArray());
            await _context.SaveChangesAsync();

            WorkspaceInfo empty = new WorkspaceInfo
            {
                Config = JsonConvert.SerializeObject(config)
            };

            _context.WorkspaceInfos.Add(empty);
            await _context.SaveChangesAsync();
        }
Example #4
0
 public Workspace(IAptDirectoryPrepService aptDirectoryPrepService, Microsoft.Extensions.Options.IOptions <WorkspaceConfig> workspaceConfig,
                  IAptCacheService aptCacheService,
                  ILogger <Workspace> logger,
                  IAptGetService aptGetService,
                  IDpkgService dpkgService,
                  IProcessRunner processRunner)
 {
     _aptDirectoryPrepService = aptDirectoryPrepService;
     _aptCacheService         = aptCacheService;
     _logger          = logger;
     _aptGetService   = aptGetService;
     _dpkgService     = dpkgService;
     _processRunner   = processRunner;
     _workspaceConfig = workspaceConfig.Value;
 }
Example #5
0
        private async Task <ConfigSet> LoadConfigurationAsync(ConfiguratorPaths paths)
        {
            WorkspaceConfig tree     = null;
            const int       retries  = 5;
            var             tryCount = retries;

            while (tryCount > 0)
            {
                try
                {
                    tryCount--;
                    tree = _configReader.GetConfigTree(paths);
                    break;
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, $"Could not open workspace '{paths.WorkspacePath}'. {tryCount} retries left");
                    await Task.Delay(1000);
                }
            }

            if (tree == null)
            {
                throw new FileLoadException($"Could not (re)load workspace after {retries} tries. Path: '{paths.WorkspacePath}'");
            }
            var effectiveConfig = tree.ToEffectiveConfig();

            using (_logger.WithHostScope(Phase.CONFIG))
            {
                _logger.LogInformation("Workspace: {WorkspaceFile}", paths.WorkspacePath);
                _logger.LogInformation(PhaseStatus.OK);
            }

            Current = effectiveConfig;
            return(effectiveConfig);
        }
Example #6
0
 public override void LoadFromWorkspaceConfig(WorkspaceConfig config) => UpdateCacheModeCheckboxes(config.AssetCacheMode);
Example #7
0
 public KrutaConfig()
 {
     WorkspaceConfig = new WorkspaceConfig();;
 }