ActiveState Powered by ActiveState

ActiveState Community


Debugging extensions?

Posted by bcorfman on 2008-04-16 05:08
OS: All / Any

I have a particularly thorny problem with using nose under Komodo -- there is a strange behavior that causes some unit tests to pass when they shouldn't, and it's only when I use the nose API from within my extension.

Is there a way to invoke pdb and step through what's happening in the nose code from within my extension? (perhaps with the Extension Developers Extension?) Or do I have to resort to logging within the nose code itself?

My extension does the following in order to call nose:
JS code -> PyXPCOM code -> nose API

Any advice/best practices welcome.

Thanks,
Brandon

ToddW | Wed, 2008-04-16 10:50

It is certainly possible to debug the Python code that is running inside of Komodo, though I'm not sure about using pdb (as I'm not sure about interaction and UI side of things). I occasionally will debug one Komodo session with another Komodo instance though. Here are some steps I use to achieve this:

  • You'll need two installations of Komodo (one for running the nose tests "KomodoNose", the other for debugging the Komodo that is running nose "Komodo")
  • You'll need to have the Komodo remote debugging dbgp client package installed in to "KomodoNose":
  •  $ cp -r /Komodo-IDE-4.3.2/lib/support/dbgp/pythonlib/dbgp/* /KomodoNose/lib/mozilla/python/komodo/dbgp/
  • In your python/nose function you wish to debug add the following:

    import dbgp.client
    # This is port "Komodo" is listening on
    dbgp.client.brk(host="localhost", port=9000)
    import dbgp.client
    # This is port "Komodo" is listening on
    dbgp.client.brk(host="localhost", port=9000)
  • Start "Komodo" (or already have it running)
  • Start "KomodoNose"
  • On triggering your code in "KomodoNose", "Komodo" should offer to start debugging and away you go ("KomodoNose" will become quite slow!)

Cheers,
Todd

bcorfman | Wed, 2008-04-16 11:23

Will this work with Komodo IDE 3.5? That's the only IDE version I have.

ToddW | Wed, 2008-04-16 13:27

If your running Komodo Edit for "KomodoNose" above, then yes this should work. I'd recommend not copying the dbgp files across to the "KomodoNose" installation, instead use the following code to setup the breakpoint:

import sys
DBGP_PATH = "/Komodo-Pro-3.5/lib/support/dbgp/pythonlib"
if DBGP_PATH not in sys.path:
    sys.path.append(DBGP_PATH)
import dbgp.client
dbgp.client.brk(host="localhost", port=9000)
import sys
DBGP_PATH = "/Komodo-Pro-3.5/lib/support/dbgp/pythonlib"
if DBGP_PATH not in sys.path:
    sys.path.append(DBGP_PATH)
import dbgp.client
dbgp.client.brk(host="localhost", port=9000)

Cheers,
Todd

bcorfman | Fri, 2008-04-18 05:05

Todd, that works great; unfortunately only with Komodo IDE 4 though. Hopefully the 21-day trial lasts long enough for me to debug my problem!

-->