From: Marco M. <ma...@mo...> - 2002-06-18 11:15:48
|
hy there, i run the following little program: ####### import sys import os import popen2 alt_stdout = sys.stdout ff = open("xx", 'w') sys.stdout = ff print "start" r,w = popen2.popen4("ls -l") l = r.read() ff.write(l) r.close() w.close() sys.stdout = alt_stdout ff.close() print "ende" ##### and i get the following error message: 22:17:19 > ../tools/jython.sh exe.py Traceback (innermost last): File "exe.py", line 11, in ? File "/home/matr/ewi/ewi/dev/jython/Lib/popen2.py", line 157, in popen4 File "/home/matr/ewi/ewi/dev/jython/Lib/popen2.py", line 98, in __init__ AttributeError: class 'org.python.modules.os' has no attribute 'pipe' what's going wrong?? is popen4 not available under jdk1.4 on linux ? ma |
From: Kevin J. B. <kev...@bi...> - 2002-06-18 16:21:26
|
Popen isn't available in Jython right now. I did some work on it a while ago, but there were some behavioral details in the CPython implementation I wasn't sure were appropriate to maintain, and didn't take it farther (pending my obligatory "lurk" period on python-dev). Tonight I'll dig up my current implementation & send it to the list. kb Marco Machmer wrote: > hy there, > > i run the following little program: > ####### > import sys > import os > import popen2 > > alt_stdout = sys.stdout > > ff = open("xx", 'w') > sys.stdout = ff > > print "start" > r,w = popen2.popen4("ls -l") > > l = r.read() > ff.write(l) > r.close() > w.close() > > > sys.stdout = alt_stdout > ff.close() > print "ende" > ##### > > and i get the following error message: > > 22:17:19 > ../tools/jython.sh exe.py > Traceback (innermost last): > File "exe.py", line 11, in ? > File "/home/matr/ewi/ewi/dev/jython/Lib/popen2.py", line 157, in > popen4 > File "/home/matr/ewi/ewi/dev/jython/Lib/popen2.py", line 98, in > __init__ > AttributeError: class 'org.python.modules.os' has no attribute 'pipe' > > what's going wrong?? > > is popen4 not available under jdk1.4 on linux ? > > ma > > > ---------------------------------------------------------------------------- > Bringing you mounds of caffeinated joy > >>> http://thinkgeek.com/sf <<< > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users |
From: Kevin J. B. <kev...@bi...> - 2002-06-19 07:08:46
|
OK, I've attached my popen2 and javaos modules. Note that these are not complete - javaos.system should use the popen2.system function, as it is a cleaner implementation of system, and it should share popen's infrastructure. There is other cleanup to be done as well (like the circular dependency on javaos), but it is pretty functional - it runs the CPython popen tests. :-) Differences from CPython: - in Jython, popen* all accept either a shell command-line, or list of arguments to execute without a shell - some of the wait/poll stuff in Popen3/4 are different, but the main functionality is available - this is first-generation code, just because it didn't break my computer doesn't mean it won't break yours. ;-) Feedback welcome... kb |
From: Kevin J. B. <kev...@bi...> - 2002-07-10 07:07:21
|
I've added popen* support to Jython in CVS. I simplified & refactored the os shell/environment functionality into a separate module (javashell.py), which is used by both javaos.py and popen2.py You can get all three modules from http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jython/jython/Lib/ Note that if you use the new javaos.py into a Jython-2.1 you'll need to comment out the from __future__ import division line. Feedback is appreciated. kb |