From f6236ffc9144ac388cbcc776a6fd0a45876a2576 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Thu, 16 Dec 2010 22:21:53 +0300 Subject: [PATCH] added diagnostic of debugger version (PY-2526) --- python/build/pycharm_build.gant | 6 +++++- python/helpers/pydev/pydevd_comm.py | 2 +- python/helpers/pydev/pydevd_utils.py | 1 - .../python/debugger/PyDebugProcess.java | 20 ++++++++++++++----- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/python/build/pycharm_build.gant b/python/build/pycharm_build.gant index 255179da8936..e77be8740432 100644 --- a/python/build/pycharm_build.gant +++ b/python/build/pycharm_build.gant @@ -130,7 +130,11 @@ def buildDebuggerEgg(paths, buildName) { fileset(dir: "$home/python/resources/debugger-egg/EGG-INFO") } - ant.replace(file: "$eggDir/EGG-INFO/PKG-INFO") { + ant.replace(file: "$eggDir/pydev/PKG-INFO") { + replacefilter(token: "@@BUILD_NUMBER@@", value: buildName) + } + + ant.replace(file: "$eggDir/pydev/pydevd_comm.py") { replacefilter(token: "@@BUILD_NUMBER@@", value: buildName) } ant.zip(destfile: egg) { diff --git a/python/helpers/pydev/pydevd_comm.py b/python/helpers/pydev/pydevd_comm.py index ad13efb961e8..ee0bd8ab796c 100644 --- a/python/helpers/pydev/pydevd_comm.py +++ b/python/helpers/pydev/pydevd_comm.py @@ -142,7 +142,7 @@ ID_TO_MEANING = { MAX_IO_MSG_SIZE = 1000 #if the io is too big, we'll not send all (could make the debugger too non-responsive) #this number can be changed if there's need to do so -VERSION_STRING = "PYCHARM-1.1" +VERSION_STRING = "@@BUILD_NUMBER@@" #--------------------------------------------------------------------------------------------------- UTILITIES diff --git a/python/helpers/pydev/pydevd_utils.py b/python/helpers/pydev/pydevd_utils.py index 58d6ccb7f41b..2993387a570b 100644 --- a/python/helpers/pydev/pydevd_utils.py +++ b/python/helpers/pydev/pydevd_utils.py @@ -36,7 +36,6 @@ def compare_object_attrs(x, y): except: return cmp(str(x), str(y)) - def cmp_to_key(mycmp): 'Convert a cmp= function into a key= function' class K(object): diff --git a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java index c11629eb4d35..9fd96ae4d61e 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java @@ -8,6 +8,7 @@ import com.intellij.execution.process.ProcessListener; import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.execution.ui.ExecutionConsole; +import com.intellij.openapi.application.ApplicationInfo; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; @@ -143,8 +144,16 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr } private void handshake() throws PyDebuggerException { - final String remoteVersion = myDebugger.handshake(); - printToConsole("Connected to pydevd (version " + remoteVersion + ")\n", ConsoleViewContentType.SYSTEM_OUTPUT); + String remoteVersion = myDebugger.handshake(); + String currentBuild = ApplicationInfo.getInstance().getBuild().asStringWithoutProductCode(); + if ("@@BUILD_NUMBER@@".equals(remoteVersion)) { + remoteVersion = currentBuild; + } + printToConsole("Connected to pydev debugger (build " + remoteVersion + ")\n", ConsoleViewContentType.SYSTEM_OUTPUT); + + if (!remoteVersion.equals(currentBuild)) { + printToConsole("Warning: wrong debugger version. Use pycharm-debugger.egg from PyCharm installation folder.", ConsoleViewContentType.ERROR_OUTPUT); + } } public void printToConsole(String text, ConsoleViewContentType contentType) { @@ -432,10 +441,11 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr public String getCurrentStateMessage() { if (getSession().isStopped()) { return XDebuggerBundle.message("debugger.state.message.disconnected"); - } else - if (myDebugger.isConnected()) { + } + else if (myDebugger.isConnected()) { return XDebuggerBundle.message("debugger.state.message.connected"); - } else { + } + else { return "Waiting for connection..."; } }