Beispiel #1
0
        public override IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console)
        {
            PythonExecutionCommand cmd = (PythonExecutionCommand)command;

            string[] args = cmd.Configuration.Runtime.GetArguments(cmd.Configuration);
            string   dir  = Path.GetFullPath(cmd.Configuration.OutputDirectory);

            NativeExecutionCommand ncmd = new NativeExecutionCommand(cmd.Configuration.Runtime.Path, string.Join(" ", args), dir, cmd.Configuration.EnvironmentVariables);

            return(base.Execute(ncmd, console));
        }
        protected override void DoExecute(IProgressMonitor monitor,
                                          ExecutionContext context,
                                          ConfigurationSelector configuration)
        {
            PythonConfiguration config;
            IConsole            console;

            config = (PythonConfiguration)GetConfiguration(configuration);

            // Make sure we have a module to execute
            if (config.Runtime == null || String.IsNullOrEmpty(config.Module))
            {
                MessageService.ShowMessage("No target module specified!");
                return;
            }

            monitor.Log.WriteLine("Running project...");

            // Create a console, external if needed
            if (config.ExternalConsole)
            {
                console = context.ExternalConsoleFactory.CreateConsole(!config.PauseConsoleOutput);
            }
            else
            {
                console = context.ConsoleFactory.CreateConsole(!config.PauseConsoleOutput);
            }

            AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor(monitor);

            try {
                PythonExecutionCommand cmd = new PythonExecutionCommand(config);

                if (!context.ExecutionHandler.CanExecute(cmd))
                {
                    monitor.ReportError("The selected execution mode is not supported for Python projects.", null);
                    return;
                }

                IProcessAsyncOperation op = context.ExecutionHandler.Execute(cmd, console);
                operationMonitor.AddOperation(op);
                op.WaitForCompleted();

                monitor.Log.WriteLine("The operation exited with code: {0}", op.ExitCode);
            }
            catch (Exception ex) {
                monitor.ReportError("Cannot execute \"" + config.Runtime.Path + "\"", ex);
            }
            finally {
                operationMonitor.Dispose();
                console.Dispose();
            }
        }
Beispiel #3
0
		protected override void DoExecute (IProgressMonitor monitor,
		                                   ExecutionContext context,
		                                   ConfigurationSelector configuration)
		{
			PythonConfiguration config;
			IConsole console;
			
			config = (PythonConfiguration) GetConfiguration (configuration);
			
			// Make sure we have a module to execute
			if (config.Runtime == null || String.IsNullOrEmpty (config.Module)) {
				MessageService.ShowMessage ("No target module specified!");
				return;
			}
			
			monitor.Log.WriteLine ("Running project...");
			
			// Create a console, external if needed
			if (config.ExternalConsole) {
				console = context.ExternalConsoleFactory.CreateConsole (!config.PauseConsoleOutput);
			}
			else {
				console = context.ConsoleFactory.CreateConsole (!config.PauseConsoleOutput);
			}
			
			AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor);
			
			try {
				PythonExecutionCommand cmd = new PythonExecutionCommand (config);
				
				if (!context.ExecutionHandler.CanExecute (cmd)) {
					monitor.ReportError ("The selected execution mode is not supported for Python projects.", null);
					return;
				}
				
				IProcessAsyncOperation op = context.ExecutionHandler.Execute (cmd, console);
				operationMonitor.AddOperation (op);
				op.WaitForCompleted ();
				
				monitor.Log.WriteLine ("The operation exited with code: {0}", op.ExitCode);
			}
			catch (Exception ex) {
				monitor.ReportError ("Cannot execute \"" + config.Runtime.Path + "\"", ex);
			}
			finally {
				operationMonitor.Dispose ();
				console.Dispose ();
			}
		}