Message5562

Author steveims
Recipients steveims
Date 2010-03-05.05:05:04
SpamBayes Score 2.29144e-08
Marked as misclassified No
Message-id <1267765504.79.0.0363168717395.issue1569@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2010-03-05 05:05:04steveimssetmessageid: <1267765504.79.0.0363168717395.issue1569@psf.upfronthosting.co.za>
2010-03-05 05:05:04steveimssetrecipients: + steveims
2010-03-05 05:05:04steveimslinkissue1569 messages
2010-03-05 05:05:04steveimscreate