Example #1
0
        public static void UseGeogridToProcessTerrestrialData(WrfConfiguration config,
                                                              IProcessLauncher processLauncher)
        {
            string geogrid = config.GeogridFilePath;

            processLauncher.LaunchProcess(geogrid, "", false);
        }
 public async Task OnExecuteAsync_Should_Create_Generator(
     IConsoleOutput console,
     IAutoRestOptions options,
     IProcessLauncher processLauncher,
     IProgressReporter progressReporter,
     IAutoRestCodeGeneratorFactory factory,
     IOpenApiDocumentFactory documentFactory,
     string swaggerFile)
 => await new AutoRestCommand(
     console,
     options,
     processLauncher,
     progressReporter,
     factory,
     documentFactory)
 {
     SwaggerFile = swaggerFile
 }
 .OnExecuteAsync()
 .ContinueWith(
     t => Mock.Get(factory)
     .Verify(
         c => c.Create(
             swaggerFile,
             "GeneratedCode",
             options,
             processLauncher,
             documentFactory)));
Example #3
0
        public static void UseWgrib2ToFindStartAndEndDatesOnWGribFiles(
            WrfConfiguration config, out DateTime startDate, out DateTime endDate,
            IProcessLauncher processLauncher, IFileSystem fileSystem)
        {
            string dataDirectory = config.DataDirectory;

            string[] files = fileSystem.GetFilesInDirectory(dataDirectory);

            // go past the period and the 'f'. ex: .f003.
            string[] orderedFiles = files.OrderByDescending(n =>
                                                            int.Parse(n.Substring(n.LastIndexOf('.') + 2))).ToArray();

            string lastFile  = orderedFiles[0];
            string firstFile = orderedFiles[orderedFiles.Length - 1];

            lastFile  = Path.Combine(dataDirectory, lastFile);
            firstFile = Path.Combine(dataDirectory, firstFile);

            string wgrib2Path = config.WGRIB2FilePath;

            //352:18979996:start_ft=2016071706
            string stdOut =
                processLauncher.LaunchProcessAndCaptureSTDOUT(wgrib2Path, $"-start_ft {firstFile}");

            startDate = GetDateTimeForStdOut(stdOut);

            stdOut =
                processLauncher.LaunchProcessAndCaptureSTDOUT(wgrib2Path, $"-start_ft {lastFile}");

            endDate = GetDateTimeForStdOut(stdOut);
        }
        public void OnExecute_Should_Create_Generator(
            IConsoleOutput console,
            IAutoRestOptions options,
            IProcessLauncher processLauncher,
            IProgressReporter progressReporter,
            IAutoRestCodeGeneratorFactory factory,
            IOpenApiDocumentFactory documentFactory,
            string swaggerFile)
        {
            new AutoRestCommand(
                console,
                options,
                processLauncher,
                progressReporter,
                factory,
                documentFactory)
            {
                SwaggerFile = swaggerFile
            }
            .OnExecute();

            Mock.Get(factory)
            .Verify(
                c => c.Create(
                    swaggerFile,
                    "GeneratedCode",
                    options,
                    processLauncher,
                    documentFactory));
        }
Example #5
0
        public static void MpiRunWrfExecutable(WrfConfiguration config, IProcessLauncher processLauncher)
        {
            string mpiRunPath        = config.MpiRunPath;
            string wrfExecutablePath = config.WrfExecutablePath;

            processLauncher.LaunchProcess(mpiRunPath, $"--allow-run-as-root -np 6 {wrfExecutablePath}", false);
        }
        public void OnExecuteAsync_Should_NotThrow(
            IConsoleOutput console,
            IAutoRestOptions options,
            IProcessLauncher processLauncher,
            IProgressReporter progressReporter,
            IAutoRestCodeGeneratorFactory factory,
            ICodeGenerator generator,
            IOpenApiDocumentFactory documentFactory,
            string outputFile,
            string code)
        {
            var sut = new AutoRestCommand(
                console,
                options,
                processLauncher,
                progressReporter,
                factory,
                documentFactory)
            {
                OutputFile = outputFile
            };

            Mock.Get(generator).Setup(c => c.GenerateCode(progressReporter)).Returns(code);
            new Func <int>(sut.OnExecute).Should().NotThrow();
        }
Example #7
0
        public static void UseMetgridToHorizontallyInterpolateData(WrfConfiguration config,
                                                                   IProcessLauncher processLauncher)
        {
            string metgridPath = config.MetgridFilePath;

            processLauncher.LaunchProcess(metgridPath, "", false);
        }
Example #8
0
 public FakeSelectorWindow(IProcessLauncher processLauncher, IConfiguration configuration, IFileSystem fileSystem, IErrorReporter errorReporter)
 {
     this.processLauncher = processLauncher;
     this.configuration   = configuration;
     this.fileSystem      = fileSystem;
     this.errorReporter   = errorReporter;
 }
 public NSwagStudioCodeGeneratorFactory(
     IGeneralOptions generalOptions,
     IProcessLauncher processLauncher)
 {
     this.generalOptions  = generalOptions ?? throw new ArgumentNullException(nameof(generalOptions));
     this.processLauncher = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
 }
Example #10
0
        public static void UseUngribToUnpackageGRIBFiles(WrfConfiguration config,
                                                         IProcessLauncher processLauncher)
        {
            string ungribPath = config.UngribFilePath;

            processLauncher.LaunchProcess(ungribPath, "", false);
        }
Example #11
0
 public OAuthLoginViewModel(Func<IOauthSession> sessionCreator, 
     IAsyncManager asyncManager, IProcessLauncher processLauncher)
 {
     _sessionCreator = sessionCreator;
     _asyncManager = asyncManager;
     _processLauncher = processLauncher;
     _getAuthorizationUrlCommand = new DelegateCommand<object>(ExecuteGetAuthorizationUrl);
 }
 protected AddNewCommandHandler(
     IProcessLauncher processLauncher,
     PackageDependencyListProvider dependencyListProvider)
 {
     process            = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
     dependencyProvider =
         dependencyListProvider ?? throw new ArgumentNullException(nameof(dependencyListProvider));
 }
Example #13
0
 public SwaggerCSharpCodeGenerator(string swaggerFile, string defaultNamespace, IGeneralOptions options, IProcessLauncher processLauncher)
 {
     this.swaggerFile      = swaggerFile ?? throw new ArgumentNullException(nameof(swaggerFile));
     this.defaultNamespace = defaultNamespace ?? throw new ArgumentNullException(nameof(defaultNamespace));
     this.options          = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher  = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
     javaPathProvider      = new JavaPathProvider(options, processLauncher);
 }
Example #14
0
 public NSwagStudioCodeGenerator(
     string nswagStudioFile,
     IGeneralOptions options,
     IProcessLauncher processLauncher)
 {
     this.nswagStudioFile = nswagStudioFile ?? throw new ArgumentNullException(nameof(nswagStudioFile));
     this.options         = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
 }
Example #15
0
 public CodeGeneratorFactory(
     IOptionsFactory optionsFactory          = null,
     IProcessLauncher processLauncher        = null,
     IOpenApiDocumentFactory documentFactory = null)
 {
     this.optionsFactory  = optionsFactory ?? new OptionsFactory();
     this.processLauncher = processLauncher ?? new ProcessLauncher();
     this.documentFactory = documentFactory ?? new OpenApiDocumentFactory();
 }
Example #16
0
        public static void UseLinkGribToCreateSymbolicLinks(WrfConfiguration config,
                                                            IProcessLauncher processLauncher)
        {
            string csh           = config.CSHFilePath;
            string linkGrib      = config.LinkGribCsh;
            string dataDirectory = config.DataDirectory;

            processLauncher.LaunchProcess(csh, $"-c \"{linkGrib} {dataDirectory}\"", true);
        }
Example #17
0
 public AutoRestSingleFileCustomTool(
     IAutoRestCodeGeneratorFactory factory,
     IAutoRestOptions options,
     IProcessLauncher processLauncher)
 {
     this.factory         = factory ?? throw new ArgumentNullException(nameof(factory));
     this.options         = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
 }
Example #18
0
 public AutoRestCSharpCodeGenerator(
     string swaggerFile,
     string defaultNamespace,
     IAutoRestOptions options,
     IProcessLauncher processLauncher)
     : base(swaggerFile, defaultNamespace, processLauncher)
 {
     this.options = options ?? throw new ArgumentNullException(nameof(options));
 }
Example #19
0
 public OpenApiSingleFileCustomTool(
     IGeneralOptions options,
     IProcessLauncher processLauncher,
     IOpenApiGeneratorFactory factory)
 {
     this.options         = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
     this.factory         = factory ?? throw new ArgumentNullException(nameof(factory));
 }
Example #20
0
        static void ComputeStage(IFileSystem iFileSystem, ILogger iLogger,
                                 IProcessLauncher iProcess, IEnvironment iEnvironment, IDatabase iDatabase,
                                 WrfConfiguration config, PhysicsConfigurationProcessed physicsConfig)
        {
            DateTime runStartTime = DateTime.Now;
            string   runId        = Guid.NewGuid().ToString().Replace("-", "");

            iLogger.LogLine("Updating physics parameters...");
            NamelistHelper.UpdatePhysicsParameters(config, physicsConfig, iFileSystem);
            iLogger.LogLine("...done");

            iLogger.LogLine("Changing directory to real directory...");
            FileSystemHelper.SetCurrentDirectoryToWRFDirectory(config, iFileSystem);
            iLogger.LogLine("...done");

            iLogger.LogLine("Launching real.exe...");
            ProcessHelper.MpiRunRealExecutable(config, iProcess);
            iLogger.LogLine("...done");

            iLogger.LogLine($"Launching wrf.exe against mp_physics={physicsConfig.MpPhysics}");
            ProcessHelper.MpiRunWrfExecutable(config, iProcess);
            iLogger.LogLine("...done");

            iLogger.LogLine("Locating the WrfOut file...");
            string wrfOutFile =
                FileSystemHelper.RetrievePathToWrfOutFile(config, iFileSystem);

            iLogger.LogLine($"...found at {wrfOutFile}.");

            iLogger.LogLine("Retrieving scripts to run...");
            string[] scripts = FileSystemHelper.RetrieveNclScriptsToRun(config, iFileSystem);
            iLogger.LogLine($"...found {scripts.Length} scripts: {string.Join(",", scripts)}");

            //string wrfOutFile = @"C:\Users\Ben\Desktop\wrfout";

            DateTime      runEndTime   = DateTime.Now;
            INetCDFReader netCdfReader = new NetCDFReader(wrfOutFile);

            DatabaseHelper.CreateRunRecord(netCdfReader, iDatabase,
                                           runStartTime, runEndTime, runId);

            LatLongRect latLongRect = ConfigurationHelper.ParseLatLongRect(config);

            DatabaseHelper.RecordVariables(netCdfReader, iDatabase,
                                           runId, latLongRect.UpperLeftLong, latLongRect.LowerRightLong,
                                           latLongRect.LowerRightLat, latLongRect.UpperLeftLat);

            foreach (string script in scripts)
            {
                iLogger.LogLine($"Launching NCL against {script}...");
                ProcessHelper.NclRunScript(config, iProcess, script, wrfOutFile);
                iLogger.LogLine("...done");

                ProcessHelper.MakeVideoWithFFMPEG(config, iProcess, script, runId);
            }
        }
Example #21
0
 public void Constructor_Requires_DependencyInstaller(IProcessLauncher launcher)
 => new Action(
     () => new SwaggerCSharpCodeGenerator(
         "",
         "",
         null,
         launcher,
         null))
 .Should()
 .ThrowExactly <ArgumentNullException>();
Example #22
0
 public ICodeGenerator Create(
     string swaggerFile,
     string defaultNamespace,
     IAutoRestOptions options,
     IProcessLauncher processLauncher)
 => new AutoRestCSharpCodeGenerator(
     swaggerFile,
     defaultNamespace,
     options,
     processLauncher);
Example #23
0
        public static void NclRunScript(WrfConfiguration config, IProcessLauncher processLauncher,
                                        string scriptName, string pathToWrfOutFile)
        {
            string scriptPath        = Path.Combine(config.ScriptsDirectory, scriptName);
            string nclExecutablePath = config.NCLPath;
            string arguments         = $"{scriptPath} netcdfFile=\\\"{pathToWrfOutFile}\\\"";

            Console.WriteLine("arguments = " + arguments);
            processLauncher.LaunchProcess(nclExecutablePath, arguments, false);
        }
        public SelectorWindow()
        {
            this.InitializeComponent();

            this.processLauncher = new ProcessLauncher();
            this.configuration   = new Configuration();
            this.fileSystem      = new FileSystem();
            this.errorReporter   = new ErrorReporter();
            this.DataContext     = this.viewModel = new SelectorWindowViewModel(this);
        }
 public SwaggerSingleFileCustomTool(
     IGeneralOptions options,
     IProcessLauncher processLauncher,
     ISwaggerCodegenFactory factory,
     IDependencyInstaller dependencyInstaller)
 {
     this.options             = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher     = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
     this.factory             = factory ?? throw new ArgumentNullException(nameof(factory));
     this.dependencyInstaller = dependencyInstaller ?? throw new ArgumentNullException(nameof(dependencyInstaller));
 }
 public SwaggerCodegenCommand(
     IConsoleOutput console,
     IProgressReporter progressReporter,
     IGeneralOptions options,
     IProcessLauncher processLauncher,
     ISwaggerCodegenFactory factory) : base(console, progressReporter)
 {
     this.options         = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
     this.factory         = factory ?? throw new ArgumentNullException(nameof(factory));
 }
 public OpenApiGeneratorCommand(
     IConsoleOutput console,
     IProgressReporter progressReporter,
     IGeneralOptions options,
     IProcessLauncher processLauncher,
     IOpenApiGeneratorFactory generatorFactory) : base(console, progressReporter)
 {
     this.options          = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher  = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
     this.generatorFactory = generatorFactory ?? throw new ArgumentNullException(nameof(generatorFactory));
 }
Example #28
0
 public CodeGeneratorFactory(
     IOptionsFactory optionsFactory          = null,
     IProcessLauncher processLauncher        = null,
     IOpenApiDocumentFactory documentFactory = null,
     IRemoteLogger remoteLogger = null)
 {
     this.optionsFactory  = optionsFactory ?? new OptionsFactory();
     this.processLauncher = processLauncher ?? new ProcessLauncher();
     this.documentFactory = documentFactory ?? new OpenApiDocumentFactory();
     this.remoteLogger    = remoteLogger ?? Logger.Instance;
 }
Example #29
0
 public AutoRestCommand(
     IConsoleOutput console,
     IAutoRestOptions options,
     IProcessLauncher processLauncher,
     IProgressReporter progressReporter,
     IAutoRestCodeGeneratorFactory factory) : base(console, progressReporter)
 {
     this.options         = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
     this.factory         = factory ?? throw new ArgumentNullException(nameof(factory));
 }
Example #30
0
 public ICodeGenerator Create(
     string swaggerFile,
     string defaultNamespace,
     IAutoRestOptions options,
     IProcessLauncher processLauncher,
     IOpenApiDocumentFactory documentFactory)
 => new AutoRestCSharpCodeGenerator(
     swaggerFile,
     defaultNamespace,
     options,
     processLauncher,
     documentFactory);
 public ICodeGenerator Create(
     string swaggerFile,
     string defaultNamespace,
     IGeneralOptions options,
     IProcessLauncher processLauncher,
     IDependencyInstaller dependencyInstaller)
 => new SwaggerCSharpCodeGenerator(
     swaggerFile,
     defaultNamespace,
     options,
     processLauncher,
     dependencyInstaller);
 public DocumentProviderImpl(IModule module, IWdDocumentRepository wdDocRepo, DPCache dpCache, DPSessionManager sessionFactory, IDPConfigurator configurator, 
     IProcessLauncher processLauncher, IFileSystemWorker fileSystemWorker, IDpLocalStorage localStorage, IWsMessage message, WdLocator locator)
 {
     _module = module;
     _wdDocRepo = wdDocRepo;
     _dpCache = dpCache;
     _sessionManager = sessionFactory;
     _dialogConfigurator = configurator;
     _processLauncher = processLauncher;
     _fileSystemWorker = fileSystemWorker;
     _localStorage = localStorage;
     _message = message;
     _isWorldoxInstalled = !string.IsNullOrEmpty(locator.NetworkWorldoxDirectory());
 }