Beispiel #1
0
            public void RedirectOutput()
            {
                var outWin = (IVsOutputWindow)HpcSupportPackage.GetGlobalService(typeof(IVsOutputWindow));
                IVsOutputWindowPane pane;

                char[] buffer = new char[1024];
                if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowDebugPane, out pane)))
                {
                    pane.Activate();

                    while (!_process.HasExited)
                    {
                        int bytesRead = _reader.Read(buffer, 0, buffer.Length);
                        pane.OutputString(new string(buffer, 0, bytesRead));
                    }

                    if (_reportExit)
                    {
                        if (_process.ExitCode != 0)
                        {
                            SetStatus("Submitting job failed.");
                        }
                    }
                }
            }
Beispiel #2
0
 private static void EnsureGeneralPane()
 {
     if (!_createdGeneralPane)
     {
         var outWin = (IVsOutputWindow)HpcSupportPackage.GetGlobalService(typeof(IVsOutputWindow));
         var guid   = VSConstants.GUID_OutWindowGeneralPane;
         outWin.CreatePane(ref guid, "General", 1, 0);
         _createdGeneralPane = true;
     }
 }
Beispiel #3
0
        private static void OutputState(string state)
        {
            var outWin = (IVsOutputWindow)HpcSupportPackage.GetGlobalService(typeof(IVsOutputWindow));
            IVsOutputWindowPane pane;

            if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowGeneralPane, out pane)))
            {
                pane.Activate();

                pane.OutputString(state + Environment.NewLine);
            }
        }
Beispiel #4
0
        private static void OnTaskStateChange(object sender, ITaskStateEventArg args)
        {
            if (args.NewState == TaskState.Failed)
            {
                var scheduler = (Scheduler)sender;
                var job       = scheduler.OpenJob(args.JobId);
                var task      = job.OpenTask(args.TaskId);

                string output = task.Output;
                if (!String.IsNullOrWhiteSpace(output))
                {
                    var outWin = (IVsOutputWindow)HpcSupportPackage.GetGlobalService(typeof(IVsOutputWindow));
                    IVsOutputWindowPane pane;
                    if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowGeneralPane, out pane)))
                    {
                        pane.Activate();
                        pane.OutputString(output);
                    }
                }
            }
        }
Beispiel #5
0
        private static void ScheduleJob(Scheduler scheduler, ISchedulerJob job)
        {
            var outWin = (IVsOutputWindow)HpcSupportPackage.GetGlobalService(typeof(IVsOutputWindow));

            IVsOutputWindowPane pane;

            if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowGeneralPane, out pane)))
            {
                pane.Activate();

                pane.OutputString("Submitting job " + job.Id + Environment.NewLine);
            }

            var    shell = (IVsUIShell)HpcSupportPackage.GetGlobalService(typeof(SVsUIShell));
            IntPtr owner;

            if (ErrorHandler.Succeeded(shell.GetDialogOwnerHwnd(out owner)))
            {
                scheduler.SetInterfaceMode(false, owner);
            }


            ThreadPool.QueueUserWorkItem(x => {
                try {
                    scheduler.SubmitJob(job, null, null);
                } catch (Exception ex) {
                    string msg;
                    msg = "Failed to submit job " + ex.ToString();
                    if (pane != null)
                    {
                        pane.OutputString(msg);
                    }
                    else
                    {
                        MessageBox.Show(msg, "Python Tools for Visual Studio");
                    }
                }
            });
        }
 public HpcSupportPackage()
 {
     Instance = this;
 }
Beispiel #7
0
        private static uint LaunchDebugger(string exe, string curDir, string projectDir, string args, string machineName, out string error)
        {
            var debugger = (IVsDebugger2)HpcSupportPackage.GetGlobalService(typeof(SVsShellDebugger));
            VsDebugTargetInfo2 debugInfo = new VsDebugTargetInfo2();

            debugInfo.cbSize = (uint)Marshal.SizeOf(typeof(VsDebugTargetInfo2));
            debugInfo.dlo    = (uint)DEBUG_LAUNCH_OPERATION.DLO_Custom;
            debugInfo.guidLaunchDebugEngine = AD7Engine.DebugEngineGuid;
            debugInfo.dwDebugEngineCount    = 1;
            debugInfo.guidPortSupplier      = new Guid("{708C1ECA-FF48-11D2-904F-00C04FA302A1}"); // local port supplier
            debugInfo.LaunchFlags           = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_WaitForAttachComplete | (uint)__VSDBGLAUNCHFLAGS5.DBGLAUNCH_BreakOneProcess;
            debugInfo.bstrRemoteMachine     = machineName;
            debugInfo.bstrExe       = exe;
            debugInfo.bstrCurDir    = curDir;
            debugInfo.bstrArg       = args;
            debugInfo.bstrOptions   = AD7Engine.DirMappingSetting + "=" + projectDir + "|" + curDir + ";" + AD7Engine.RedirectOutputSetting + "=True";
            debugInfo.pDebugEngines = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Guid)));

            if (debugInfo.pDebugEngines == IntPtr.Zero)
            {
                error = "Out of memory";
                return(0);
            }

            try {
                Marshal.StructureToPtr(AD7Engine.DebugEngineGuid, debugInfo.pDebugEngines, false);

                IntPtr memory = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(VsDebugTargetInfo2)));
                if (memory == IntPtr.Zero)
                {
                    error = "Out of memory";
                    return(0);
                }

                try {
                    Marshal.StructureToPtr(debugInfo, memory, false);

                    int hr = debugger.LaunchDebugTargets2(1, memory);

                    if (ErrorHandler.Failed(hr))
                    {
                        var    uiShell = (IVsUIShell)HpcSupportPackage.GetGlobalService(typeof(SVsUIShell));
                        string errorText;
                        if (ErrorHandler.Succeeded(uiShell.GetErrorInfo(out errorText)))
                        {
                            error = errorText;
                        }
                        else
                        {
                            error = "Unknown error";
                        }
                        return(0);
                    }
                    else
                    {
                        var structure = (VsDebugTargetInfo2)Marshal.PtrToStructure(memory, typeof(VsDebugTargetInfo2));

                        error = "";
                        return(structure.dwProcessId);
                    }
                } finally {
                    Marshal.FreeCoTaskMem(memory);
                }
            } finally {
                //Marshal.FreeCoTaskMem(debugInfo.pDebugEngines);
            }
        }
Beispiel #8
0
 public HpcSupportPackage() {
     Instance = this;
 }
Beispiel #9
0
        private static void SetStatus(string text)
        {
            var statusBar = (IVsStatusbar)HpcSupportPackage.GetGlobalService(typeof(SVsStatusbar));

            statusBar.SetText(text);
        }