Esempio n. 1
0
 public static void RunCommand(string[] inputArgs, CommandStatusWriter consoleOut)
 {
     using (CommandLine cmd = new CommandLine(consoleOut))
     {
         cmd.Run(inputArgs);
     }
 }
Esempio n. 2
0
 public CommandLine(CommandStatusWriter output)
 {
     _out = output;
 }
Esempio n. 3
0
 public AddZipToolHelper(CommandLine.ResolveZipToolConflicts? howToResolve, bool? howToResolveAnnotations,
     CommandStatusWriter output,
     string fileName, ProgramPathContainer ppc, string inputProgramPath,
     bool arePackagesHandled)
 {
     resolveToolsAndReports = howToResolve;
     overwriteAnnotations = howToResolveAnnotations;
     _out = output;
     zipFileName = fileName;
     programPathContainer = ppc;
     programPath = inputProgramPath;
     packagesHandled = arePackagesHandled;
 }
Esempio n. 4
0
 public PanoramaPublishHelper(CommandStatusWriter statusWriter)
 {
     _statusWriter = statusWriter;
 }
Esempio n. 5
0
 private static bool ShareDocument(SrmDocument document, string documentPath, string fileDest, CommandStatusWriter statusWriter)
 {
     var waitBroker = new CommandProgressMonitor(statusWriter,
         new ProgressStatus(Resources.SkylineWindow_ShareDocument_Compressing_Files));
     var sharing = new SrmDocumentSharing(document, documentPath, fileDest, false);
     try
     {
         sharing.Share(waitBroker);
         return true;
     }
     catch (Exception x)
     {
         statusWriter.WriteLine(Resources.SkylineWindow_ShareDocument_Failed_attempting_to_create_sharing_file__0__, fileDest);
         statusWriter.WriteLine(x.Message);
     }
     return false;
 }
 private static string RunCommand(params string[] inputArgs)
 {
     var consoleBuffer = new StringBuilder();
     var consoleOutput = new CommandStatusWriter(new StringWriter(consoleBuffer));
     CommandLineRunner.RunCommand(inputArgs, consoleOutput);
     return consoleBuffer.ToString();
 }
Esempio n. 7
0
        // TODO: Test the case where the imported replicate has the wrong path without Lorenzo's data
        //[TestMethod]
        public void TestLorenzo()
        {
            var consoleBuffer = new StringBuilder();
            var consoleOutput = new CommandStatusWriter(new StringWriter(consoleBuffer));

            var testFilesDir = new TestFilesDir(TestContext, COMMAND_FILE);

            string docPath = testFilesDir.GetTestPath("VantageQCSkyline.sky");
            string tsvPath = testFilesDir.GetTestPath("Exported_test_report.csv");
            string dataPath = testFilesDir.GetTestPath("VantageQCSkyline.skyd");

            var args = new[]
                           {
                               "--in=" + docPath,
                               "--import-file=" + dataPath,
                               "--report-name=TestQCReport",
                               "--report-file=" + tsvPath,
                               "--report-format=TSV"
                           };

            //There are no tests. This is for debugging.
            CommandLineRunner.RunCommand(args, consoleOutput);
        }
Esempio n. 8
0
        /// <summary>
        /// This function will try for 5 seconds to open a named pipe ("SkylineInputPipe").
        /// If this operation is not successful, the function will exit. Otherwise,
        /// the function will print each line received from the pipe
        /// out to the console and then wait for a newline from the user.
        /// </summary>
        public void Start(string arg0)
        {
            string guidSuffix = RemoveCommandPrefix(arg0);

            List<string> args = new List<string>();
            using (NamedPipeClientStream pipeStream = new NamedPipeClientStream("SkylineInputPipe" + guidSuffix)) // Not L10N
            {
                // The connect function will wait 5s for the pipe to become available
                try
                {
                    pipeStream.Connect(5 * 1000);
                }
                catch (Exception)
                {
                    // Nothing to output, because no connection to command-line process.
                    return;
                }

                using (StreamReader sr = new StreamReader(pipeStream))
                {
                    string line;
                    //While (!done reading)
                    while ((line = sr.ReadLine()) != null)
                    {
                        args.Add(line);
                    }
                }
            }

            string outPipeName = "SkylineOutputPipe" + guidSuffix; // Not L10N
            using (var serverStream = new NamedPipeServerStream(outPipeName)) // Not L10N
            {
                var namedPipeServerConnector = new NamedPipeServerConnector();
                if (!namedPipeServerConnector.WaitForConnection(serverStream, outPipeName))
                {
                    return;
                }
                using (var sw = new CommandStatusWriter(new StreamWriter(serverStream)))
                {
                    RunCommand(args.ToArray(), sw);
                }
            }
        }
Esempio n. 9
0
        public static void Main(string[] args = null)
        {
            if (String.IsNullOrEmpty(Settings.Default.InstallationId)) // Each instance to have GUID
                Settings.Default.InstallationId = Guid.NewGuid().ToString();

            // don't allow 64-bit Skyline to run in a 32-bit process
            if (Install.Is64Bit && !Environment.Is64BitProcess)
            {
                string installUrl = Install.Url;
                string installLabel = (installUrl == string.Empty) ? string.Empty : string.Format(Resources.Program_Main_Install_32_bit__0__, Name);
                AlertLinkDlg.Show(null,
                    string.Format(Resources.Program_Main_You_are_attempting_to_run_a_64_bit_version_of__0__on_a_32_bit_OS_Please_install_the_32_bit_version, Name),
                    installLabel,
                    installUrl);
                return;
            }

            CommonFormEx.TestMode = FunctionalTest;
            CommonFormEx.Offscreen = SkylineOffscreen;
            CommonFormEx.ShowFormNames = FormEx.ShowFormNames = ShowFormNames;

            // For testing and debugging Skyline command-line interface
            if (args != null && args.Length > 0)
            {
                if (!CommandLineRunner.HasCommandPrefix(args[0]))
                {
                    var writer = new CommandStatusWriter(new DebugWriter());
                    if (args[0].Equals("--ui", StringComparison.InvariantCultureIgnoreCase)) // Not L10N
                    {
                        // ReSharper disable once ObjectCreationAsStatement
                        new CommandLineUI(args, writer);
                    }
                    else
                    {
                        CommandLineRunner.RunCommand(args, writer);
                    }
                }
                else
                {
                    // For testing SkylineRunner without installation
                    CommandLineRunner clr = new CommandLineRunner();
                    clr.Start(args[0]);
                }

                return;
            }
            // The way Skyline command-line interface is run for an installation
            else if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null &&
                AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null &&
                AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Length > 0 &&
                CommandLineRunner.HasCommandPrefix(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0])) // Not L10N
            {
                CommandLineRunner clr = new CommandLineRunner();
                clr.Start(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]);

                // HACK: until the "invalid string binding" error is resolved, this will prevent an error dialog at exit
                Process.GetCurrentProcess().Kill();
                return;
            }

            try
            {
                Init();
                if (!string.IsNullOrEmpty(Settings.Default.DisplayLanguage))
                {
                    try
                    {
                        LocalizationHelper.CurrentUICulture =
                            CultureInfo.GetCultureInfo(Settings.Default.DisplayLanguage);
                    }
                    catch (CultureNotFoundException)
                    {
                    }
                }
                LocalizationHelper.InitThread(Thread.CurrentThread);

                // Make sure the user has agreed to the current license version
                // or one more recent.
                int licenseVersion = Settings.Default.LicenseVersionAccepted;
                if (licenseVersion < LICENSE_VERSION_CURRENT && !NoSaveSettings)
                {
                    // If the user has never used the application before, then
                    // they must have agreed to the current license agreement during
                    // installation.  Otherwise, make sure they agree to the new
                    // license agreement.
                    if (Install.Type == Install.InstallType.release &&
                            (licenseVersion != 0 || !Settings.Default.MainWindowSize.IsEmpty))
                    {
                        using (var dlg = new UpgradeDlg(licenseVersion))
                        {
                            if (dlg.ShowDialog() == DialogResult.Cancel)
                                return;
                        }
                    }

                    try
                    {
                        // Make sure the user never sees this again for this license version
                        Settings.Default.LicenseVersionAccepted = LICENSE_VERSION_CURRENT;
                        Settings.Default.Save();
                    }
            // ReSharper disable EmptyGeneralCatchClause
                    catch (Exception)
            // ReSharper restore EmptyGeneralCatchClause
                    {
                        // Just try to update the license version next time.
                    }
                }

                try
                {
                    // If this is a new installation copy over installed external tools from previous installation location.
                    var toolsDirectory = ToolDescriptionHelpers.GetToolsDirectory();
                    if (!Directory.Exists(toolsDirectory))
                    {
                        using (var longWaitDlg = new LongWaitDlg
                        {
                            Text = Name,
                            Message = Resources.Program_Main_Copying_external_tools_from_a_previous_installation,
                            ProgressValue = 0
                        })
                        {
                            longWaitDlg.PerformWork(null, 1000*3, broker => CopyOldTools(toolsDirectory, broker));
                        }
                    }
                }
                // ReSharper disable once EmptyGeneralCatchClause
                catch
                {

                }

                // Force live reports (though tests may reset this)
                //Settings.Default.EnableLiveReports = true;

                if (ReportShutdownDlg.HadUnexpectedShutdown())
                {
                    using (var reportShutdownDlg = new ReportShutdownDlg())
                    {
                        reportShutdownDlg.ShowDialog();
                    }
                }
                SystemEvents.DisplaySettingsChanged += SystemEventsOnDisplaySettingsChanged;
                // Careful, a throw out of the SkylineWindow constructor without this
                // catch causes Skyline just to appear to silently never start.  Makes for
                // some difficult debugging.
                try
                {
                    var activationArgs = AppDomain.CurrentDomain.SetupInformation.ActivationArguments;
                    if ((activationArgs != null &&
                        activationArgs.ActivationData != null &&
                        activationArgs.ActivationData.Length != 0) ||
                        !Settings.Default.ShowStartupForm)
                    {
                        MainWindow = new SkylineWindow(args);
                    }
                    else
                    {
                        StartWindow = new StartPage();
                        try
                        {
                            if (StartWindow.ShowDialog() != DialogResult.OK)
                            {
                                Application.Exit();
                                return;
                            }

                            MainWindow = StartWindow.MainWindow;
                        }
                        finally
                        {
                            StartWindow.Dispose();
                            StartWindow = null;
                        }
                    }
                }
                catch (Exception x)
                {
                    ReportExceptionUI(x, new StackTrace(1, true));
                }

                ConcurrencyVisualizer.StartEvents(MainWindow);

                // Position window offscreen for stress testing.
                if (SkylineOffscreen)
                    FormEx.SetOffscreen(MainWindow);

                ActionUtil.RunAsync(() =>
                {
                    try {
                        SendAnalyticsHit();
                    } catch (Exception ex) {
                        Trace.TraceWarning("Exception sending analytics hit {0}", ex);  // Not L10N
                    }
                });
                MainToolServiceName = Guid.NewGuid().ToString();
                Application.Run(MainWindow);
                StopToolService();
            }
            catch (Exception x)
            {
                // Send unhandled exceptions to the console.
                Console.WriteLine(x.Message);
                Console.Write(x.StackTrace);
            }

            MainWindow = null;
        }
Esempio n. 10
0
 private static SrmDocument InitWatersImsMseDocument(TestFilesDir testFilesDir, string skyFile, 
     RefinementSettings.ConvertToSmallMoleculesMode asSmallMolecules,
     out string docPath)
 {
     docPath = testFilesDir.GetTestPath(skyFile);
     var consoleBuffer = new StringBuilder();
     var consoleOutput = new CommandStatusWriter(new StringWriter(consoleBuffer));
     var cmdline = new CommandLine(consoleOutput);
     Assert.IsTrue(cmdline.OpenSkyFile(docPath)); // Handles any path shifts in database files, like our .imdb file
     SrmDocument doc = cmdline.Document;
     var refine = new RefinementSettings();
     doc = refine.ConvertToSmallMolecules(doc, asSmallMolecules);
     return doc;
 }
Esempio n. 11
0
        public CommandArgs(CommandStatusWriter output, bool isDocumentLoaded)
        {
            ResolveToolConflictsBySkipping = null;
            ResolveSkyrConflictsBySkipping = null;
            _out = output;
            _isDocumentLoaded = isDocumentLoaded;

            ReportColumnSeparator = TextUtil.CsvSeparator;
            MaxTransitionsPerInjection = AbstractMassListExporter.MAX_TRANS_PER_INJ_DEFAULT;
            ImportOptimizeType = OPT_NONE;
            ExportOptimizeType = OPT_NONE;
            ExportStrategy = ExportStrategy.Single;
            ExportMethodType = ExportMethodType.Standard;
            PrimaryTransitionCount = AbstractMassListExporter.PRIMARY_COUNT_DEFAULT;
            DwellTime = AbstractMassListExporter.DWELL_TIME_DEFAULT;
            RunLength = AbstractMassListExporter.RUN_LENGTH_DEFAULT;

            SearchResultsFiles = new List<string>();

            ImportBeforeDate = null;
            ImportOnOrAfterDate = null;
        }