[Pydev-cvs] org.python.pydev.debug/src/org/python/pydev/debug/ui/launching PythonRunner.java,1.15,1.
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2005-07-13 12:41:18
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10637/src/org/python/pydev/debug/ui/launching Modified Files: PythonRunner.java Log Message: trying to fix some problems Index: PythonRunner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/PythonRunner.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PythonRunner.java 10 Jul 2005 19:52:36 -0000 1.15 --- PythonRunner.java 13 Jul 2005 12:41:05 -0000 1.16 *************** *** 10,13 **** --- 10,14 ---- import java.net.SocketTimeoutException; import java.util.HashMap; + import java.util.Map; import org.eclipse.core.runtime.CoreException; *************** *** 34,37 **** --- 35,59 ---- public class PythonRunner { + /** + * @param p + * @param process + * @throws CoreException + */ + private static void checkProcess(Process p, IProcess process) throws CoreException { + if (process == null) { + p.destroy(); + throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR, "Could not register with debug plugin?", null)); + } + } + /** + * @param p + * @throws CoreException + */ + private static void checkProcess(Process p) throws CoreException { + if (p == null) + throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR,"Could not execute python process. Was it cancelled?", null)); + } + + /** * Launches the configuration *************** *** 69,76 **** Process p = DebugPlugin.exec(cmdLine, config.workingDirectory, config.envp); ! if (p == null) ! throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR,"Could not execute python process. Was it cancelled?", null)); IProcess process = registerWithDebugPlugin(config, launch, p); subMonitor.subTask("Waiting for connection..."); --- 91,98 ---- Process p = DebugPlugin.exec(cmdLine, config.workingDirectory, config.envp); ! checkProcess(p); IProcess process = registerWithDebugPlugin(config, launch, p); + checkProcess(p, process); subMonitor.subTask("Waiting for connection..."); *************** *** 99,121 **** } public static void doIt(IProgressMonitor monitor, String [] envp, String[] cmdLine, File workingDirectory, ILaunch launch) throws CoreException{ if (monitor == null) monitor = new NullProgressMonitor(); IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 5); subMonitor.beginTask("Launching python", 1); ! // Launch & connect to the debugger subMonitor.subTask("Constructing command_line..."); subMonitor.subTask("Exec..."); Process p = DebugPlugin.exec(cmdLine, workingDirectory, envp); ! if (p == null) ! throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR, "Could not execute python process. Was it cancelled?", null)); ! // Register the process with the debug plugin subMonitor.subTask("Done"); ! registerWithDebugPlugin(PythonRunnerConfig.getCommandLineAsString(cmdLine), cmdLine[cmdLine.length-1], launch, p); ! } --- 121,152 ---- } + public static void doIt(IProgressMonitor monitor, String [] envp, String[] cmdLine, File workingDirectory, ILaunch launch) throws CoreException{ if (monitor == null) monitor = new NullProgressMonitor(); IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 5); + subMonitor.beginTask("Launching python", 1); ! // Launch & connect to the debugger subMonitor.subTask("Constructing command_line..."); + String commandLineAsString = PythonRunnerConfig.getCommandLineAsString(cmdLine); + Map processAttributes = new HashMap(); + processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); + processAttributes.put(IProcess.ATTR_CMDLINE, commandLineAsString); subMonitor.subTask("Exec..."); + //it was dying before register, so, I made this faster to see if this fixes it Process p = DebugPlugin.exec(cmdLine, workingDirectory, envp); ! checkProcess(p); ! IProcess process = registerWithDebugPlugin(cmdLine[cmdLine.length-1], launch, p, processAttributes); ! checkProcess(p, process); ! ! // Registered the process with the debug plugin subMonitor.subTask("Done"); ! ! } *************** *** 135,140 **** Process p = DebugPlugin.exec(cmdLine, config.workingDirectory, config.envp); ! if (p == null) ! throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR, "Could not execute python process. Was it cancelled?", null)); int port = config.getUnitTestPort(); --- 166,176 ---- Process p = DebugPlugin.exec(cmdLine, config.workingDirectory, config.envp); ! checkProcess(p); ! ! IProcess process = registerWithDebugPlugin(PythonRunnerConfig.getCommandLineAsString(cmdLine), cmdLine[cmdLine.length-1], launch, p); ! checkProcess(p, process); ! ! // Register the process with the debug plugin ! subMonitor.subTask("Done"); int port = config.getUnitTestPort(); *************** *** 151,157 **** } - // Register the process with the debug plugin - subMonitor.subTask("Done"); - registerWithDebugPlugin(PythonRunnerConfig.getCommandLineAsString(cmdLine), cmdLine[cmdLine.length-1], launch, p); } } --- 187,190 ---- *************** *** 165,169 **** processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); processAttributes.put(IProcess.ATTR_CMDLINE, config.getCommandLineAsString()); ! return DebugPlugin.newProcess(launch,p, config.resource.lastSegment(), processAttributes); } --- 198,202 ---- processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); processAttributes.put(IProcess.ATTR_CMDLINE, config.getCommandLineAsString()); ! return registerWithDebugPlugin(config.resource.lastSegment(), launch,p, processAttributes); } *************** *** 176,180 **** processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); processAttributes.put(IProcess.ATTR_CMDLINE, cmdLine); ! return DebugPlugin.newProcess(launch,p, label, processAttributes); } } --- 209,221 ---- processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); processAttributes.put(IProcess.ATTR_CMDLINE, cmdLine); ! return registerWithDebugPlugin(label, launch,p, processAttributes); ! } ! ! /** ! * The debug plugin needs to be notified about our process. ! * It'll then display the appropriate UI. ! */ ! public static IProcess registerWithDebugPlugin(String label, ILaunch launch, Process p, Map processAttributes) { ! return DebugPlugin.newProcess(launch,p, label, processAttributes); } } |