os.system() - problem when using with lynx browser in linux
Hi I've created an external method that runs the lynx browser on linux and which dumps the output to a temporary file for display on a web page in zope. But the output from the dump is limited to 20k in size (I began with a script that dumped to a file on the hard drive rather than a temporary file) which provided this figure. The problem is that most pages are larger than the dump size that's allowed when I use the method in zope - so the output from the script is usually truncated. external method------ def execute(url,fileName): import string, os, tempfile try: fileName =tempfile.mktemp() lynx=('/usr/bin/lynx -accept_all_cookies -dump - hiddenlinks=ignore ') lynx=lynx + url lynx=lynx + ' > ' lynx=lynx + fileName os.system(lynx) out=open(fileName,'r').read() os.remove(fileName) return out except: error='Sorry - service not available - please try again' return error I've also tried os.popen() and have the same problem. I've tried running a similar script in straight python and do not find the same problem. Is this an issue with python in zope - I use a binary of zope 2.5 rather than my own python? Or is this the way that zope is set up and there's a configuration I'm missing? Any suggestions? Thanks Jim
Jim Whitman wrote:
But the output from the dump is limited to 20k in size (I began with a script that dumped to a file on the hard drive rather than a temporary file) which provided this figure.
Is the 20k limit the problem? It's not clear from your post... Chris
out=open(fileName,'r').read()
os.remove(fileName)
return out
...
I've tried running a similar script in straight python and do not find the same problem.
Is this an issue with python in zope - I use a binary of zope 2.5 rather than my own python? Or is this the way that zope is set up and there's a configuration I'm missing?
Any suggestions?
Try return str(out) Totally guessing, of course. --jcc -- "Code generators follow the 80/20 rule. They solve most of the problems, but not all of the problems. There are always features and edge cases that will need hand-coding. Even if code generation could build 100 percent of the application, there will still be an endless supply of boring meetings about feature design." (http://www.devx.com/java/editorial/15511)
Hi Thanks to those who helped. I've discovered that the problem was the lack of a tmpdir environment variable for Lynx that caused it to exit before completing its download of a page. It was confused as to who it was running as within a Zope-run python script. Best wishes On 11 Sep 2003 at 7:02, Jim Whitman wrote: From: "Jim Whitman" <jim@jameswhitman.org> To: zope@zope.org Date sent: Thu, 11 Sep 2003 07:02:01 +1200 Priority: normal Subject: [Zope] os.system() - problem when using with lynx browser in linux
Hi I've created an external method that runs the lynx browser on linux and which dumps the output to a temporary file for display on a web page in zope.
But the output from the dump is limited to 20k in size (I began with a script that dumped to a file on the hard drive rather than a temporary file) which provided this figure. The problem is that most pages are larger than the dump size that's allowed when I use the method in zope - so the output from the script is usually truncated.
external method------
def execute(url,fileName):
import string, os, tempfile
try:
fileName =tempfile.mktemp()
lynx=('/usr/bin/lynx -accept_all_cookies -dump - hiddenlinks=ignore ')
lynx=lynx + url
lynx=lynx + ' > '
lynx=lynx + fileName
os.system(lynx)
out=open(fileName,'r').read()
os.remove(fileName)
return out
except:
error='Sorry - service not available - please try again'
return error
I've also tried os.popen() and have the same problem.
I've tried running a similar script in straight python and do not find the same problem.
Is this an issue with python in zope - I use a binary of zope 2.5 rather than my own python? Or is this the way that zope is set up and there's a configuration I'm missing?
Any suggestions? Thanks Jim
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Chris Withers -
J Cameron Cooper -
Jim Whitman