public Task <ExecutionResult> InitializeAsync() { _commands = PythonInteractiveEvaluator.GetInteractiveCommands(_serviceProvider, CurrentWindow, this); CurrentWindow.TextView.Options.SetOptionValue(InteractiveWindowOptions.SmartUpDown, CurrentOptions.UseSmartHistory); CurrentWindow.WriteLine("Python debug interactive window. Type $help for a list of commands."); CurrentWindow.ReadyForInput += OnReadyForInput; return(ExecutionResult.Succeeded); }
public static CommandProcessorThread Create( PythonInteractiveEvaluator evaluator, Stream stream ) { var thread = new CommandProcessorThread(evaluator, null); thread._stream = stream; thread.StartOutputThread(false); return(thread); }
public static CommandProcessorThread Create( PythonInteractiveEvaluator evaluator, Socket listenerSocket, Process process ) { var thread = new CommandProcessorThread(evaluator, process); thread._listenerSocket = listenerSocket; thread.StartOutputThread(process.StartInfo.RedirectStandardOutput); return(thread); }
private IInteractiveEvaluator GetEnvironmentEvaluator(IReadOnlyList <string> args) { var config = _interpreterService.FindConfiguration(args.ElementAtOrDefault(1)); var eval = new PythonInteractiveEvaluator(_serviceProvider) { DisplayName = args.ElementAtOrDefault(0), Configuration = new LaunchConfiguration(config) }; return(eval); }
public static CommandProcessorThread Create( PythonInteractiveEvaluator evaluator, Stream stream ) { var thread = new CommandProcessorThread(evaluator, null); thread._stream = stream; // Should be quickly replaced, but it's the best guess we have thread._currentWorkingDirectory = Environment.CurrentDirectory; thread.StartOutputThread(false); return(thread); }
private IInteractiveEvaluator GetProjectEvaluator(IReadOnlyList <string> args) { var project = args.ElementAtOrDefault(1); var eval = new PythonInteractiveEvaluator(_serviceProvider) { DisplayName = args.ElementAtOrDefault(0), ProjectMoniker = project }; eval.UpdatePropertiesFromProjectMoniker(); return(eval); }
private IInteractiveEvaluator GetEnvironmentEvaluator(IReadOnlyList <string> args) { var config = _interpreterService.FindConfiguration(args.ElementAtOrDefault(1)); var eval = new PythonInteractiveEvaluator(_serviceProvider) { DisplayName = args.ElementAtOrDefault(0), Configuration = new LaunchConfiguration(config) }; eval.Configuration.SearchPaths = _serviceProvider.GetPythonToolsService().GetGlobalPythonSearchPaths(config).ToList(); return(eval); }
private IInteractiveEvaluator GetWorkspaceEvaluator(IReadOnlyList <string> args) { _serviceProvider.MustBeCalledFromUIThread(); var workspace = args.ElementAtOrDefault(1); var eval = new PythonInteractiveEvaluator(_serviceProvider) { DisplayName = args.ElementAtOrDefault(0), WorkspaceMoniker = workspace }; eval.UpdatePropertiesFromWorkspaceMoniker(); return(eval); }
public Task <ExecutionResult> InitializeAsync() { _commands = PythonInteractiveEvaluator.GetInteractiveCommands(_serviceProvider, CurrentWindow, this); var langBuffer = CurrentWindow.CurrentLanguageBuffer; if (langBuffer != null) { // Reinitializing, and our new language buffer does not automatically // get connected to the Intellisense controller. Let's fix that. var controller = IntellisenseControllerProvider.GetController(CurrentWindow.TextView); controller?.ConnectSubjectBuffer(langBuffer); } CurrentWindow.TextView.Options.SetOptionValue(InteractiveWindowOptions.SmartUpDown, CurrentOptions.UseSmartHistory); CurrentWindow.WriteLine(Strings.DebugReplHelpMessage); CurrentWindow.ReadyForInput += OnReadyForInput; return(ExecutionResult.Succeeded); }
private CommandProcessorThread(PythonInteractiveEvaluator evaluator, Process process) { _process = process; _eval = evaluator; _preConnectionOutput = new StringBuilder(); }
private IInteractiveEvaluator GetEnvironmentEvaluator(IReadOnlyList<string> args) { var config = _interpreterService.FindConfiguration(args.ElementAtOrDefault(1)); var eval = new PythonInteractiveEvaluator(_serviceProvider) { DisplayName = args.ElementAtOrDefault(0), Configuration = new LaunchConfiguration(config) }; return eval; }
public void BadInterpreterPath() { // http://pytools.codeplex.com/workitem/662 var replEval = new PythonInteractiveEvaluator(PythonToolsTestUtilities.CreateMockServiceProvider()) { DisplayName = "Test Interpreter", Configuration = new LaunchConfiguration(new InterpreterConfiguration("InvalidInterpreter", "Test Interpreter", path: "C:\\Does\\Not\\Exist\\Some\\Interpreter.exe")) }; var replWindow = new MockReplWindow(replEval); replEval._Initialize(replWindow); var execute = replEval.ExecuteText("42"); var errorText = replWindow.Error; const string expected = "the associated Python environment could not be found."; if (!errorText.Contains(expected)) { Assert.Fail(string.Format( "Did not find:\n{0}\n\nin:\n{1}", expected, errorText )); } }
public async Task NoInterpreterPath() { // http://pytools.codeplex.com/workitem/662 var replEval = new PythonInteractiveEvaluator(PythonToolsTestUtilities.CreateMockServiceProvider()) { DisplayName = "Test Interpreter" }; var replWindow = new MockReplWindow(replEval); await replEval._Initialize(replWindow); await replEval.ExecuteText("42"); Console.WriteLine(replWindow.Error); Assert.IsTrue( replWindow.Error.Contains("Test Interpreter cannot be started"), "Expected: <Test Interpreter cannot be started>\r\nActual: <" + replWindow.Error + ">" ); }
private static void TestOutput(MockReplWindow window, PythonInteractiveEvaluator evaluator, string code, bool success, Action<bool> afterExecute, bool equalOutput, int timeout = 3000, params string[] expectedOutput) { window.ClearScreen(); bool completed = false; var task = evaluator.ExecuteText(code).ContinueWith(completedTask => { Assert.AreEqual(success, completedTask.Result.IsSuccessful); var output = success ? window.Output : window.Error; if (equalOutput) { if (output.Length == 0) { Assert.IsTrue(expectedOutput.Length == 0); } else { // don't count ending \n as new empty line output = output.Replace("\r\n", "\n"); if (output[output.Length - 1] == '\n') { output = output.Remove(output.Length - 1, 1); } var lines = output.Split('\n'); if (lines.Length != expectedOutput.Length) { for (int i = 0; i < lines.Length; i++) { Console.WriteLine("{0}: {1}", i, lines[i].ToString()); } } Assert.AreEqual(lines.Length, expectedOutput.Length); for (int i = 0; i < expectedOutput.Length; i++) { Assert.AreEqual(lines[i], expectedOutput[i]); } } } else { foreach (var line in expectedOutput) { Assert.IsTrue(output.Contains(line), string.Format("'{0}' does not contain '{1}'", output, line)); } } completed = true; }); if (afterExecute != null) { afterExecute(completed); } try { task.Wait(timeout); } catch (AggregateException ex) { if (ex.InnerException != null) { throw ex.InnerException; } throw; } if (!completed) { Assert.Fail(string.Format("command didn't complete in {0} seconds", timeout / 1000.0)); } }
private static void TestOutput(MockReplWindow window, PythonInteractiveEvaluator evaluator, string code, bool success, params string[] expectedOutput) { TestOutput(window, evaluator, code, success, null, true, 3000, expectedOutput); }
private IInteractiveEvaluator GetProjectEvaluator(IReadOnlyList<string> args) { var project = args.ElementAtOrDefault(1); var eval = new PythonInteractiveEvaluator(_serviceProvider) { DisplayName = args.ElementAtOrDefault(0), ProjectMoniker = project }; eval.UpdatePropertiesFromProjectMoniker(); return eval; }
public static CommandProcessorThread Create( PythonInteractiveEvaluator evaluator, Stream stream ) { var thread = new CommandProcessorThread(evaluator, null); thread._stream = stream; // Should be quickly replaced, but it's the best guess we have thread._currentWorkingDirectory = Environment.CurrentDirectory; thread.StartOutputThread(false); return thread; }
public static CommandProcessorThread Create( PythonInteractiveEvaluator evaluator, Socket listenerSocket, Process process ) { var thread = new CommandProcessorThread(evaluator, process); thread._listenerSocket = listenerSocket; thread._currentWorkingDirectory = process.StartInfo.WorkingDirectory; thread.StartOutputThread(process.StartInfo.RedirectStandardOutput); return thread; }
private static PythonInteractiveEvaluator MakeEvaluator() { var python = PythonPaths.Python27 ?? PythonPaths.Python27_x64 ?? PythonPaths.Python26 ?? PythonPaths.Python26_x64; python.AssertInstalled(); var provider = new SimpleFactoryProvider(python.InterpreterPath, python.InterpreterPath); var eval = new PythonInteractiveEvaluator(PythonToolsTestUtilities.CreateMockServiceProvider()) { Configuration = new LaunchConfiguration(python.Configuration) }; Assert.IsTrue(eval._Initialize(new MockReplWindow(eval)).Result.IsSuccessful); return eval; }
public static CommandProcessorThread Create( PythonInteractiveEvaluator evaluator, Stream stream ) { var thread = new CommandProcessorThread(evaluator, null); thread._stream = stream; thread.StartOutputThread(false); return thread; }