[Pydev-cvs] org.python.pydev.debug/src/org/python/pydev/debug/ui/launching PythonRunner.java,1.1,1.2
Brought to you by:
fabioz
From: Aleksandar T. <at...@us...> - 2004-04-15 23:24:59
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17142/src/org/python/pydev/debug/ui/launching Modified Files: PythonRunner.java PythonRunnerConfig.java LaunchShortcut.java PythonLaunchConfigurationDelegate.java Removed Files: PythonDebugTabGroup.java PythonTab.java Log Message: Removed the duplicate Tab definitions Index: PythonRunner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/PythonRunner.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonRunner.java 29 Mar 2004 17:07:25 -0000 1.1 --- PythonRunner.java 15 Apr 2004 23:24:49 -0000 1.2 *************** *** 72,83 **** } ! /** ! * launches the debug configuration ! * @param config ! * @param launch ! * @param monitor ! * @throws CoreException ! */ ! public void run(PythonRunnerConfig config, ILaunch launch, IProgressMonitor monitor) throws CoreException, IOException { if (monitor == null) monitor = new NullProgressMonitor(); --- 72,76 ---- } ! public void runDebug(PythonRunnerConfig config, ILaunch launch, IProgressMonitor monitor) throws CoreException, IOException { if (monitor == null) monitor = new NullProgressMonitor(); *************** *** 97,111 **** Process p = DebugPlugin.exec(cmdLine, config.workingDirectory); if (p == null) - // TODO this might not be an error throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Could not execute python process. Was it cancelled?", null)); // Register the process with the debug plugin subMonitor.worked(2); subMonitor.subTask("Starting debugger..."); - HashMap processAttributes = new HashMap(); - processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); - processAttributes.put(IProcess.ATTR_CMDLINE, config.getCommandLineAsString()); - IProcess process = DebugPlugin.newProcess(launch,p, config.file.lastSegment(), processAttributes); - // Launch the debug listener on a thread, and wait until it completes while (connectThread.isAlive()) { --- 90,100 ---- Process p = DebugPlugin.exec(cmdLine, config.workingDirectory); if (p == null) throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Could not execute python process. Was it cancelled?", null)); + + IProcess process = registerWithDebugPlugin(config, launch, p); // Register the process with the debug plugin subMonitor.worked(2); subMonitor.subTask("Starting debugger..."); // Launch the debug listener on a thread, and wait until it completes while (connectThread.isAlive()) { *************** *** 149,152 **** --- 138,184 ---- dt.start(); } + + /** + * launches the debug configuration + * @param config + * @param launch + * @param monitor + * @throws CoreException + */ + public void run(PythonRunnerConfig config, ILaunch launch, IProgressMonitor monitor) throws CoreException, IOException { + if (config.isDebug) { + runDebug(config, launch, monitor); + return; + } + 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[] cmdLine = config.getCommandLine(); + subMonitor.worked(1); + + subMonitor.subTask("Exec..."); + Process p = DebugPlugin.exec(cmdLine, config.workingDirectory); + if (p == null) + throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Could not execute python process. Was it cancelled?", null)); + + // Register the process with the debug plugin + subMonitor.worked(2); + subMonitor.subTask("Done"); + registerWithDebugPlugin(config, launch, p); + } + + /** + * TODO document + */ + private IProcess registerWithDebugPlugin(PythonRunnerConfig config, ILaunch launch, Process p) { + HashMap processAttributes = new HashMap(); + processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); + processAttributes.put(IProcess.ATTR_CMDLINE, config.getCommandLineAsString()); + return DebugPlugin.newProcess(launch,p, config.file.lastSegment(), processAttributes); + } protected void checkErrorMessage(IProcess process) throws CoreException { Index: PythonLaunchConfigurationDelegate.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/PythonLaunchConfigurationDelegate.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PythonLaunchConfigurationDelegate.java 29 Mar 2004 17:07:25 -0000 1.4 --- PythonLaunchConfigurationDelegate.java 15 Apr 2004 23:24:49 -0000 1.5 *************** *** 29,33 **** * <p>I would have subclassed, but ProgramLaunchDelegate hides important internals * ! * @see org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate */ public class PythonLaunchConfigurationDelegate implements ILaunchConfigurationDelegate --- 29,33 ---- * <p>I would have subclassed, but ProgramLaunchDelegate hides important internals * ! * Based on org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate */ public class PythonLaunchConfigurationDelegate implements ILaunchConfigurationDelegate --- PythonDebugTabGroup.java DELETED --- --- PythonTab.java DELETED --- Index: LaunchShortcut.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/LaunchShortcut.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LaunchShortcut.java 29 Mar 2004 17:07:25 -0000 1.3 --- LaunchShortcut.java 15 Apr 2004 23:24:49 -0000 1.4 *************** *** 32,35 **** --- 32,36 ---- import org.eclipse.ui.dialogs.ElementListSelectionDialog; import org.python.pydev.debug.core.*; + import org.python.pydev.plugin.PydevPrefs; /** *************** *** 39,43 **** * <p>Launches the "Run python..." window * <p>code almost all copied from AntLaunchShortcut: ! * @see org.eclipse.ui.externaltools.internal.ant.launchConfigurations.AntLaunchShortcut */ public class LaunchShortcut implements ILaunchShortcut { --- 40,44 ---- * <p>Launches the "Run python..." window * <p>code almost all copied from AntLaunchShortcut: ! * Based on org.eclipse.ui.externaltools.internal.ant.launchConfigurations.AntLaunchShortcut */ public class LaunchShortcut implements ILaunchShortcut { *************** *** 154,158 **** String baseDirectory = file.getRawLocation().removeLastSegments(1).toString(); String arguments = ""; ! String interpreter = PydevDebugPlugin.getDefault().getInterpreters()[0]; workingCopy.setAttribute(Constants.ATTR_LOCATION,location); workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY,baseDirectory); --- 155,159 ---- String baseDirectory = file.getRawLocation().removeLastSegments(1).toString(); String arguments = ""; ! String interpreter = PydevPrefs.getInterpreters()[0]; workingCopy.setAttribute(Constants.ATTR_LOCATION,location); workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY,baseDirectory); Index: PythonRunnerConfig.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/PythonRunnerConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonRunnerConfig.java 29 Mar 2004 17:07:25 -0000 1.1 --- PythonRunnerConfig.java 15 Apr 2004 23:24:49 -0000 1.2 *************** *** 21,25 **** import org.python.pydev.debug.core.Constants; import org.python.pydev.debug.core.PydevDebugPlugin; - import org.python.pydev.debug.ui.InterpreterEditor; /** --- 21,24 ---- *************** *** 108,112 **** cmdArgs.add(interpreter); // Next option is for unbuffered stdout, otherwise Eclipse will not see any output until done ! cmdArgs.add(InterpreterEditor.isJython(interpreter) ? "-i" : "-u"); if (isDebug) { // rpdb cmdArgs.add(debugScript); --- 107,111 ---- cmdArgs.add(interpreter); // Next option is for unbuffered stdout, otherwise Eclipse will not see any output until done ! cmdArgs.add(org.python.pydev.ui.InterpreterEditor.isJython(interpreter) ? "-i" : "-u"); if (isDebug) { // rpdb cmdArgs.add(debugScript); |