Exemple #1
0
        public static void LaunchAnalysisTool(AnalysisTool analysisTool, string vizConfigPath, Dataset mergedDataset, string dataDirectoryPath)
        {
            Console.WriteLine(vizConfigPath);

            string logPath          = System.IO.Path.Combine(System.IO.Path.GetTempPath(), string.Format("{0}_{1:yyyyMMdd_HHmmss}.log", analysisTool.InternalName, DateTime.Now));
            var    exePath          = ExpandAnalysisToolString(analysisTool.ExecutableFilePath, vizConfigPath, dataDirectoryPath);
            var    arguments        = ExpandAnalysisToolString(analysisTool.ProcessArguments, vizConfigPath, dataDirectoryPath);
            var    workingDirectory = ExpandAnalysisToolString(analysisTool.WorkingDirectory, vizConfigPath, dataDirectoryPath);

            ProcessStartInfo psi = new ProcessStartInfo()
            {
                FileName         = "cmd.exe",
                Arguments        = string.Format("/S /C \"\"{0}\" {1} > \"{2}\" 2>&1\"", exePath, arguments, logPath),
                CreateNoWindow   = true,
                WindowStyle      = ProcessWindowStyle.Hidden,
                WorkingDirectory = workingDirectory,
                // RedirectStandardError = true,
                // RedirectStandardOutput = true,
                UseShellExecute = true //UseShellExecute must be true to prevent subprocess from inheriting listening sockets from PETBrowser.exe--  which causes problems at next launch if PETBrowser terminates
            };

            if (analysisTool.ShowConsoleWindow)
            {
                psi.Arguments      = string.Format("/S /C \"\"{0}\" {1}", exePath, arguments, logPath);
                psi.CreateNoWindow = false;
                psi.WindowStyle    = ProcessWindowStyle.Normal;
            }

            Console.WriteLine(psi.Arguments);
            var p = new Process();

            p.StartInfo           = psi;
            p.EnableRaisingEvents = true;
            AddRunningSession(vizConfigPath, mergedDataset, dataDirectoryPath);
            p.Start();

            p.Exited += (sender, args) => { RemoveRunningSession(vizConfigPath, mergedDataset, dataDirectoryPath); };
        }
Exemple #2
0
            public MergedDirectoryWatcher(Dataset mergedDataset, string dataDirectoryPath)
            {
                ReferenceCount    = 1;
                Watchers          = new List <FileSystemWatcher>();
                MergedDataset     = mergedDataset;
                DataDirectoryPath = dataDirectoryPath;

                var mergedDirectory = Path.Combine(dataDirectoryPath, DatasetStore.MergedDirectory,
                                                   mergedDataset.Folders[0]);
                List <Dataset> sourceDatasets = new List <Dataset>();

                using (
                    var reader =
                        File.OpenText(Path.Combine(mergedDirectory, "metadata.json")))
                {
                    var serializer = new JsonSerializer();
                    var metadata   = (MergedPetMetadata)serializer.Deserialize(reader, typeof(MergedPetMetadata));

                    sourceDatasets.AddRange(metadata.SourceDatasets);
                }

                foreach (var dataset in sourceDatasets)
                {
                    if (dataset.Kind == Dataset.DatasetKind.PetResult)
                    {
                        foreach (var folder in dataset.Folders)
                        {
                            var testbenchManifestFilePath = Path.Combine(dataDirectoryPath, DatasetStore.ResultsDirectory, folder);
                            var directoryToWatch          = Directory.GetParent(testbenchManifestFilePath).FullName;
                            if (Directory.Exists(directoryToWatch))
                            {
                                Console.WriteLine("Watching {0}", directoryToWatch);
                                var watcher = new FileSystemWatcher(directoryToWatch);
                                //watcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.LastWrite | NotifyFilters.LastAccess | NotifyFilters.FileName | NotifyFilters.DirectoryName;
                                watcher.Filter = "output.csv";

                                watcher.Changed += OnChanged;
                                watcher.Created += OnChanged;
                                watcher.Deleted += OnChanged;
                                watcher.Renamed += OnRenamed;

                                watcher.EnableRaisingEvents = true;

                                Watchers.Add(watcher);
                            }
                            else
                            {
                                Console.WriteLine("Not watching {0}; it doesn't appear to exist", directoryToWatch);
                            }
                        }
                    }
                    else
                    {
                        // Don't live refresh anything except PetResult datasets
                    }
                }



                Console.WriteLine("Started watching dataset at {0}", mergedDirectory);
            }