Subversion Repositories SmartDukaan

Rev

Rev 70 | Rev 344 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * 
 */
package in.shop2020.util;

import org.python.util.PythonInterpreter;

/**
 * Wrapper around work done by Jython scripts
 * 
 * @author naveen
 *
 */
public class JythonWrapper {
        
        /**
         * Private Python interpreter instance
         */
        protected PythonInterpreter py = null;

        
        /**
         * Initialises PythonInterpreter instance 
         */
        public void initialize() {
                if(this.py == null) {
                        this.py = new PythonInterpreter();
                }
        }
        
        /**
         * Resets current PythonInterpreter instance
         */
        public void reset() {
                this.py = null;
        }
        
        /**
         * Executes Jython script given absolute path
         * 
         * @param filename
         */
        public void exec(String filename) {
                this.initialize();
                
                this.py.execfile(filename);
        }
}