Search in sources :

Example 1 with HttpProtocolUtils

use of org.python.pydev.shared_core.io.HttpProtocolUtils in project Pydev by fabioz.

the class DebuggerReader method run.

/**
 * keep reading until we finish (that should happen when an exception is thrown, or if it is set as
 * done from outside)
 *
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    HttpProtocolUtils httpProtocol = new HttpProtocolUtils();
    ICallback<String, Object> onUnexpectedMessage = (unexpectedMessage) -> {
        String msg = "It seems an old version of the PyDev Debugger is being used (please update the pydevd package being used).\n\nFound message:\n" + unexpectedMessage;
        RunInUiThread.async(() -> {
            PyDialogHelpers.openCritical("Error", msg);
        });
        Log.log(msg);
        return null;
    };
    while (!done) {
        String contents;
        try {
            if ((contents = httpProtocol.readContents(in, onUnexpectedMessage)) == null) {
                done = true;
            } else {
                if (contents.length() > 0) {
                    processCommand(contents.toString());
                }
            }
        } catch (Exception e1) {
            done = true;
            // that's ok, it means that the client finished
            if (DEBUG) {
                e1.printStackTrace();
            }
        }
        if (done || socket == null || !socket.isConnected()) {
            AbstractDebugTarget target = remote;
            if (target != null) {
                target.terminate();
            }
            done = true;
        }
    }
}
Also used : Socket(java.net.Socket) AbstractDebugTarget(org.python.pydev.debug.model.AbstractDebugTarget) IOException(java.io.IOException) RunInUiThread(org.python.pydev.shared_ui.utils.RunInUiThread) PyDialogHelpers(org.python.pydev.ui.dialogs.PyDialogHelpers) PydevDebugPlugin(org.python.pydev.debug.core.PydevDebugPlugin) IStatus(org.eclipse.core.runtime.IStatus) AbstractDebugTargetWithTransmission(org.python.pydev.debug.model.AbstractDebugTargetWithTransmission) HttpProtocolUtils(org.python.pydev.shared_core.io.HttpProtocolUtils) ICallback(org.python.pydev.shared_core.callbacks.ICallback) Dictionary(java.util.Dictionary) Hashtable(java.util.Hashtable) Log(org.python.pydev.core.log.Log) InputStream(java.io.InputStream) HttpProtocolUtils(org.python.pydev.shared_core.io.HttpProtocolUtils) AbstractDebugTarget(org.python.pydev.debug.model.AbstractDebugTarget) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Socket (java.net.Socket)1 Dictionary (java.util.Dictionary)1 Hashtable (java.util.Hashtable)1 IStatus (org.eclipse.core.runtime.IStatus)1 Log (org.python.pydev.core.log.Log)1 PydevDebugPlugin (org.python.pydev.debug.core.PydevDebugPlugin)1 AbstractDebugTarget (org.python.pydev.debug.model.AbstractDebugTarget)1 AbstractDebugTargetWithTransmission (org.python.pydev.debug.model.AbstractDebugTargetWithTransmission)1 ICallback (org.python.pydev.shared_core.callbacks.ICallback)1 HttpProtocolUtils (org.python.pydev.shared_core.io.HttpProtocolUtils)1 RunInUiThread (org.python.pydev.shared_ui.utils.RunInUiThread)1 PyDialogHelpers (org.python.pydev.ui.dialogs.PyDialogHelpers)1