[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] Axiom crashing in Zope-Plone
From: |
Bob McElrath |
Subject: |
Re: [Axiom-developer] Axiom crashing in Zope-Plone |
Date: |
Sat, 25 Sep 2004 10:33:07 -0700 |
User-agent: |
Mutt/1.5.6+20040523i |
The original version of runCommand (and your example below) fails if
your program creates a large amount of output. I only discovered the
bug recently when re-rendering one of my pages with a lot of latex.
You should grab latexwiki from my repository::
http://bob.mcelrath.org/darcs/latexwiki
which is the official source for that, then 'darcs pull' from::
http://page.axiom-developer.org/repository
which has the axiom patches. These will be integrated to latexwiki
eventually -- right now the axiom patches duplicate a lot of code
(including runCommand). If someone wants to clean this up, I will
accept patches! ;) I've just been busy lately. Physics comes first...
The fixed runCommand is::
# Make our file descriptors nonblocking so that reading doesn't hang.
def makeNonBlocking(f):
fl = fcntl.fcntl(f.fileno(), FCNTL.F_GETFL)
fcntl.fcntl(f.fileno(), FCNTL.F_SETFL, fl | os.O_NONBLOCK)
def runCommand(cmdLine):
program = popen2.Popen3('cd %s; '%(workingDir) + cmdLine, 1)
program.tochild.close()
makeNonBlocking(program.fromchild)
makeNonBlocking(program.childerr)
stderr = []
stdout = []
erreof = False
outeof = False
while(not (erreof and outeof)):
readme, writme, xme = select.select([program.fromchild,
program.childerr], [], [])
for output in readme:
if(output == program.fromchild):
text = program.fromchild.read()
if(text == ''): outeof = True
else: stdout.append(text)
elif(output == program.childerr):
text = program.childerr.read()
if(text == ''): erreof = True
else: stderr.append(text)
status = program.wait()
error = os.WEXITSTATUS(status) or not os.WIFEXITED(status)
return error, string.join(stdout, ''), string.join(stderr, '')
Hans Peter Wuermli address@hidden wrote:
>
> Hi
>
> I wonder if someone with the new Zope-Plone-LatexWiki experience can help me.
>
> Having been enthusiastic about MathAction I tried to set it up locally on my
> local computer, too, using the ZWiki and LatexWiki files on
> http://page.axiom-developer.org/repository. Strangely enough Axiom is not
> rendered, as the method runCommand() in axiomWrapper.py fails when run from
> inside Zope. Testing the method externally either within a zope.app() or as a
> standalone method, does not produce errors and works as expected.
>
> I checked with a lot of analoguous situations, first suspecting missing
> access
> rights, but "wrapping", for example, an executable, a segfaulting executable
> or a psql script run fine, standalone or within zope as external methods.
>
> I can boil down the error to the external method "demo.py" at the end of the
> mail, which is similar to the runCommand() in axiomWrapper.py.
>
> Zope is version 2.6.4; python used is version 2.2 and it all runs on a Debian
> sarge system.
>
> The exit codes for Popen3 when run from Zope are:
>
> WEXITSTATUS:139
> WIFEXITED: 1
>
> Thank you for any help.
>
> Cheers, H.P.
>
>
> demo.py:
>
> import os
> from popen2 import Popen3
>
>
> axiomTemplate = r""")set output algebra off
> )set output tex on
> )set message autoload off
> )set quit unprotected
> integrate(x**2,x)
> )quit
> """
>
> LatexWikiHome = '/usr/lib/zope/lib/python\
> /Products/LatexWiki/Extensions/'
>
> axTinput = open ( LatexWikiHome + 'axT.input', 'w' )
> axTinput.write(axiomTemplate)
> axTinput.close()
>
> cmdLine = r'export AXIOM=/usr/lib/axiom-0.20040831;\
> export PATH=$AXIOM/bin:$PATH;\
> AXIOMsys < %s ' %(LatexWikiHome + 'axT.input')
>
> def echoWorld():
> """ external method calling Popen3 """
> p = Popen3 (cmdLine, 1, 4096)
> status = p.wait()
> p.tochild.close()
> out = p.fromchild.read()
> p.fromchild.close()
> err = ''
> if p.childerr: err = p.childerr.read(); p.childerr.close()
> error = os.WEXITSTATUS(status) or \
> not os.WIFEXITED(status)
> if not error: return\
> 'Output: ' + out +\
> '\nWEXITSTATUS: ' + str(os.WEXITSTATUS(status)) +\
> '\nWIFEXITED: ' + str(os.WIFEXITED(status))
> else: return\
> 'Error: ' + err +\
> '\nOut: ' + out +\
> '\nWEXITSTATUS:' + str(os.WEXITSTATUS(status)) +\
> '\nWIFEXITED: ' + str(os.WIFEXITED(status))
>
> # For Zope external testing
> print echoWorld()
>
>
> _______________________________________________
> Axiom-developer mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/axiom-developer
--
Cheers,
Bob McElrath [Univ. of California at Davis, Department of Physics]
It is unpatriotic to question the Kleptocracy.
signature.asc
Description: Digital signature
- [Axiom-developer] Axiom crashing in Zope-Plone, Hans Peter Wuermli, 2004/09/25
- Re: [Axiom-developer] Axiom crashing in Zope-Plone, Hans Peter Wuermli, 2004/09/26
- RE: [Axiom-developer] Axiom crashing in Zope-Plone, Bill Page, 2004/09/26
- Re: [Axiom-developer] Axiom crashing in Zope-Plone, Hans Peter Wuermli, 2004/09/26
- Re: [Axiom-developer] Axiom crashing in Zope-Plone, Bob McElrath, 2004/09/26
- Re: [Axiom-developer] Axiom crashing in Zope-Plone, root, 2004/09/26
- Re: [Axiom-developer] Axiom crashing in Zope-Plone, Camm Maguire, 2004/09/26
- Re: [Axiom-developer] Axiom crashing in Zope-Plone, Camm Maguire, 2004/09/28
- Re: [Axiom-developer] Axiom crashing in Zope-Plone, Hans Peter Wuermli, 2004/09/28