From 81e236a7e9d33d6a8afa5406924542fb461145d2 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Mon, 9 Sep 2013 12:25:32 +0200 Subject: [PATCH] Set value implemented for console variables view. --- python/helpers/pydev/pydevconsole.py | 11 +++++++++-- .../python/console/PydevConsoleCommunication.java | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/python/helpers/pydev/pydevconsole.py b/python/helpers/pydev/pydevconsole.py index e26d82b1f0d6..3c21acd02e08 100644 --- a/python/helpers/pydev/pydevconsole.py +++ b/python/helpers/pydev/pydevconsole.py @@ -194,9 +194,15 @@ class InterpreterInterface(BaseInterpreterInterface): xml += pydevd_vars.varToXML(valDict[k], to_string(k)) xml += "" - - return xml + return xml + + def changeVariable(self, attr, value): + try: + Exec('%s=%s' % (attr, value), self.namespace, self.namespace) + except: + pass + def close(self): sys.exit(0) @@ -300,6 +306,7 @@ def start_server(host, port, interpreter): server.register_function(interpreter.getCompletions) server.register_function(interpreter.getFrame) server.register_function(interpreter.getVariable) + server.register_function(interpreter.changeVariable) server.register_function(interpreter.getDescription) server.register_function(interpreter.close) server.register_function(interpreter.interrupt) diff --git a/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java b/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java index c741f73aa81f..c897680f88e7 100644 --- a/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java +++ b/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java @@ -46,6 +46,7 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl private static final String GET_DESCRIPTION = "getDescription"; private static final String GET_FRAME = "getFrame"; private static final String GET_VARIABLE = "getVariable"; + private static final String CHANGE_VARIABLE = "changeVariable"; private static final String HANDSHAKE = "handshake"; private static final String CLOSE = "close"; /** @@ -469,7 +470,14 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl } @Override - public void changeVariable(PyDebugValue variable, String expression) throws PyDebuggerException { - //To change body of implemented methods use File | Settings | File Templates. + public void changeVariable(PyDebugValue variable, String value) throws PyDebuggerException { + if (myClient != null) { + try { + myClient.execute(CHANGE_VARIABLE, new Object[]{variable.getEvaluationExpression(), value}); + } + catch (XmlRpcException e) { + throw new PyDebuggerException("Get change variable", e); + } + } } }