On Wed, Sep 14, 2011 at 8:42 AM, Edward K. Ream <[email protected]> wrote:

> 2. Modify pdb.py in blender/2.59/python/lib

As expected, there appears to be no way to run pdb from the Blender
console window.  The Blender developers actually appear to take pride
in limiting what can be done from Python.

However, I now have a workaround that will work for some purposes.  It
follows a tip at:
http://www.blender.org/documentation/blender_python_api_2_59_2/info_tips_and_tricks.html

The trick is to run Blender in background mode, from a console, as follows::

    blender --background --python ekr_test.py

For example, ekr_test is::

    import edb
    import bpy
    edb.set_trace()
    print(bpy)
    for z in dir(bpy):
        print(z)
    print('done')

Here edb is my version of pdb.py, located in Blender\2.59\python\lib

I have spent several hours hacking the code so that it can use the
proper source code in ekr_test.py. I have long wondered why the
standard pdb module doesn't do a better job with showing the proper
sources. The hack I came up with is to call _getval('__file__') to get
the file name when otherwise the file name would be reported as
'<string>'.

The usual complications ensue: the hack has to be done in lots of
places, and has other, mostly minor, side effects.  Now that I know
what works, I might be able to clean up the code a bit.

In any case, I can now get a proper listing, and set breakpoints, and
generally use edb as I please.  Provided that I run Blender in the
background, that is.

I'll be posting the code for the edb.py when it is cleaned up.  I'll
probably make edb a subclass of pdb.Pdb, so that only changed code
will need to be appear explicitly. I'm still debating whether to do
this.  Subclassing pdb.Pdb is the typical way, but putting all the
code in one place is clearer.  And it avoid problems when the base
classes change...

> 3. Use winpdb

This is still a real possibility.  The advantage may be that one can
run scripts remotely while Blender is in the foreground.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to