// do nothing
}
protected void processImpl( Template pTemplate ) {
Template template = pTemplate;
PropertySet tmps = template.getMergedPropertySet();
boolean successful = false;
PrintStream sysOut = null;
PrintStream sysErr = null;
RecordingUserMessageHandler rumh = new RecordingUserMessageHandler();
try {
String cw = tmps.get( Property.main_CodeWriter );
String cwo = makeCodeWriterOptions( tmps, template );
String[] args = ArgUtil.splitQuoted( cwo );
String cwp = getCodeWriterPath( tmps );
Properties jythonProps = new Properties();
jythonProps.put( "python.home", tmps.get("jython.home") );
PythonInterpreter.initialize( System.getProperties(), jythonProps, args );
PyStringMap dict = new PyStringMap();
PySystemState pysys = new PySystemState();
PythonInterpreter pi = new PythonInterpreter( dict, pysys );
// DO NOT use CommandLineUserMessageHandler here - causes infinite recursion
MessageHandlerOutputStream out = new MessageHandlerOutputStream( UserMessageHandler.INFO, rumh );
MessageHandlerOutputStream err = new MessageHandlerOutputStream( UserMessageHandler.ERROR, rumh );
// space out dots to avoid accidental replace on System DOT out search
sysOut = System . out;
sysErr = System . err;
// set context if not null
Object context = template.getContext();
if( null != context ) {
pi.set( "context", context );
}
System.setOut( new PrintStream( out ) );
System.setErr( new PrintStream( err ) );
pi.execfile( cwp );
String jythonexec
= "cw = "+cw+"()\n"
+ (null!=context?"cw._setContext( context )\n":"")
+ "cw.main( sys.argv )\n"
+ "result = cw._getResult()\n"
;
pi.exec( jythonexec );
WayPointRecorder.add( BasicWayPoint.ExecutingCodeWriter.make( template.getCodeWriterPath().getAbsolutePath() ) );
Object result = pi.get("result");
if( result instanceof Integer ) {
successful = ( 0 == ((Integer)result).intValue() );
}
else {
successful = true;
}
template.setResult( result );
}
// FIX: need a util to handle general exceptions and just rethrow StandardExceptions
catch( StandardException se ) {
throw se;