Message5562
Appears I cannot upload files, so I'll copy the example here.
First, the .java which embeds Jython:
.....................................
package simple;
import java.io.ByteArrayOutputStream;
import org.python.util.PythonInterpreter;
public class JythonTest {
public static void main(String[] argv) {
PythonInterpreter interp = new PythonInterpreter();
ByteArrayOutputStream os = new ByteArrayOutputStream();
interp.setOut(os);
System.out.println("Output written directly to stdout (problem: bypassed the specified output stream):");
System.out.println("===================================================================================");
interp.execfile("test.py");
System.out.println("");
System.out.println("Output written to the output stream (as expected):");
System.out.println("==================================================");
System.out.println("os received: [" + os.toString() + "]");
}
}
And here's test.py:
...................
import subprocess
import sys
print "from print; "
sys.stdout.write("from sys.stdout; ")
sys.stdout.flush()
subprocess.call(["echo", "from subprocess.call without stdout; "])
subprocess.call(["echo", "from subprocess.call with stdout; "], stdout=sys.stdout) |
|
Date |
User |
Action |
Args |
2010-03-05 05:05:04 | steveims | set | messageid: <1267765504.79.0.0363168717395.issue1569@psf.upfronthosting.co.za> |
2010-03-05 05:05:04 | steveims | set | recipients:
+ steveims |
2010-03-05 05:05:04 | steveims | link | issue1569 messages |
2010-03-05 05:05:04 | steveims | create | |
|