DebugClients/Python3/DebugUtilities.py

branch
jsonrpc
changeset 5129
e4ab234cf071
parent 4631
5c1a96925da4
diff -r b6cbdba69967 -r e4ab234cf071 DebugClients/Python3/DebugUtilities.py
--- a/DebugClients/Python3/DebugUtilities.py	Fri Sep 02 19:14:41 2016 +0200
+++ b/DebugClients/Python3/DebugUtilities.py	Fri Sep 02 19:50:20 2016 +0200
@@ -123,5 +123,27 @@
         argvalues += " -> " + formatvalue(locals['__return__'])
     return argvalues
 
+
+def prepareJsonCommand(method, params):
+    """
+    Function to prepare a single command or response for transmission to
+    the IDE.
+    
+    @param method command or response name to be sent
+    @type str
+    @param params dictionary of named parameters for the command or response
+    @type dict
+    @return prepared JSON command or response string
+    @rtype str
+    """
+    import json
+    
+    commandDict = {
+        "jsonrpc": "2.0",
+        "method": method,
+        "params": params,
+    }
+    return json.dumps(commandDict) + '\n'
+
 #
 # eflag: noqa = M702

eric ide

mercurial