Re: How do I find out from inside pdb which namespace contains an object?

2008-08-03 Thread Jonathan Mark
Never mind. I had to run "import collective.dancing" first.
--
http://mail.python.org/mailman/listinfo/python-list


How do I find out from inside pdb which namespace contains an object?

2008-08-03 Thread Jonathan Mark
I am inside a Pdb-like Plone debugging tool and I get the following
error at the prompt. I was wondering how to find out from inside the
debugger which namespace the collective.dancing.channel object is
located in. :

collective.dancing.channel.tool_added(DelegateNichols.portal_newsletters,
None)
collective.dancing.channel.tool_added(DelegateNichols.portal_newsletters,
None)
002
Traceback (most recent call last):
  File "", line 1, in ?
NameError: name 'collective' is not defined
--
http://mail.python.org/mailman/listinfo/python-list


Is there any way to automatically create a transcript of an interactive Python session?

2007-02-18 Thread Jonathan Mark
Some languages, such as Scheme, permit you to make a transcript of an
interactive console session. Is there a way to do that in Python?

-- 
http://mail.python.org/mailman/listinfo/python-list


13 second delay using select() with Popen3()

2006-12-21 Thread Jonathan Mark
hi all...

I wrote a seemingly simple function (below) to use Popen3() and select() 
to run a program and capture its exit status, stdout output, and stderr 
output.

It worked fine until the box was upgraded to Debian sarge.
Now the call to select() always takes about 13 seconds before returning 
the first time.
The delay only occurs when the function is running within a CGI program 
invoked by Apache (v2.2).
If I run the same thing from a shell in the same environment, there is 
no delay.
The correct result is always returned; the only problem is the 13-second 
delay.

The command passed as "cmd" runs a bash script which looks at some local 
files and prints one line of output and then does "exit 0".
Python is v2.4.4 (can't use 2.5 because I am using Zope which doesn't 
support it yet).

I would appreciate any suggestions or advice about whether I got the 
select loop wrong somehow, or what else might be wrong.  Thanks!!

Jonathan Mark
---
import os, popen2, select

def execCommand(cmd, mergeErrors = False):
 popen3 = popen2.Popen3(cmd, capturestderr = True)
 popen3.tochild.close()

 strOutput = ''
 strErrors = ''
 fdOutputFrom = popen3.fromchild.fileno()
 fdlistFrom = [fdOutputFrom, popen3.childerr.fileno()]
 while fdlistFrom:
 fdlistReadable, fdlistWriteable, fdlistError = select.select(
 fdlistFrom, [], fdlistFrom)
 for fd in fdlistError:
 raise AssertionError('file I/O error with child process')
 for fd in fdlistReadable:
 data = os.read(fd, 8192)
 if data:
 if mergeErrors or fd is fdOutputFrom:
 strOutput += data
 else:
 strErrors += data
 else:
 fdlistFrom.remove(fd)
 popen3.fromchild.close()
 popen3.childerr.close()
 return popen3.wait(), strOutput, strErrors
-- 
http://mail.python.org/mailman/listinfo/python-list