Examples of PythonInterpreter


Examples of org.python.util.PythonInterpreter

        FileInputStream in = null;

        try
        {
            in = new FileInputStream(scriptFile);
            PythonInterpreter interp = new PythonInterpreter();
            initEnvironment(interp);
            interp.execfile(in);
        }
        catch (FileNotFoundException ex)
        {
            Logger.getLogger(ScriptRunner.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here

Examples of org.python.util.PythonInterpreter

     *
     * @see #EditorConfig()
     */
    public EditorConfig(List<String> jarLocations)
            throws PythonException {
        pyInterp = new PythonInterpreter(null, new PySystemState());
        PySystemState pySysStat = Py.getSystemState();

        // Add all "jarLocations/Lib" to sys.path
        if(jarLocations != null)
            for(String jarPath : jarLocations)
View Full Code Here

Examples of org.python.util.PythonInterpreter

    public void registerFunctions(String path, String namespace, PigContext pigContext)
    throws IOException {
        Interpreter.setMain(false);
        Interpreter.init(path, pigContext);
        pigContext.addScriptJar(getJarPath(PythonInterpreter.class));
        PythonInterpreter pi = Interpreter.interpreter;
        @SuppressWarnings("unchecked")
        List<PyTuple> locals = ((PyStringMap) pi.getLocals()).items();
        namespace = (namespace == null) ? "" : namespace + NAMESPACE_SEPARATOR;
        try {
            for (PyTuple item : locals) {
                String key = (String) item.get(0);
                Object value = item.get(1);
View Full Code Here

Examples of org.python.util.PythonInterpreter

                 //Debug.logInfo(props.toString(), module);
                 ClassLoader loader = Thread.currentThread().getContextClassLoader();
                 PySystemState.initialize(props, pyProps, new String[0], loader);

                 SINGLETON  =  new PythonInterpreter();

                 SINGLETON.exec("import sys");
                 SINGLETON.exec("sys.path.append(\"c:/dev/ag/seleniumXml/plugins\")");
             }
         }
View Full Code Here

Examples of org.python.util.PythonInterpreter

    }

    private void initData() {
        // Run the python script
        // Read header and get record count
        PythonInterpreter interp = InitJython.getInterpreter();

        Map<String, Object> map = FastMap.newInstance();
        map.put("file", this.file);
        interp.set("params", map);

        interp.exec("from csvreader import CSVReader");
        String cmd = "reader = CSVReader('" + this.file + "')";
        interp.exec(cmd);
        this.dataList = (PyList) interp.eval("reader.dataList");
        this.fieldNames = (PyList) interp.eval("reader.fieldNames");
        this.fieldNameMap = (PyDictionary) interp.eval("reader.fieldNameMap");
        //interp.execfile("c:/dev/ag/seleniumxml/plugins/csvreader.py");
        //interp.execfile("c:/dev/ag/seleniumxml/plugins/TestCSVReader.py");

        //Now get output from script
        //this.dataList = (PyArray) map.get("dataList");
View Full Code Here

Examples of org.python.util.PythonInterpreter

        this.parent = parent;
    }

    public void runTest() {

        PythonInterpreter interp = InitJython.getInterpreter();

        Map<String, Object> map = this.parent.getMap();
        map.put("url", this.urlName);
        try {
            String scriptText = TestUtils.readUrlText(this.urlName);
            interp.set("context", map);
            interp.exec(scriptText);
        } catch(MalformedURLException e) {
            System.out.println("Scriptrunner, runTest, MalformedURLException error: " + e.getMessage());
        } catch(IOException e) {
            System.out.println("Scriptrunner, runTest, IOException error: " + e.getMessage());
        }
View Full Code Here

Examples of org.python.util.PythonInterpreter

*/
public class JPythonInterpreter implements org.apache.batik.script.Interpreter {
    private PythonInterpreter interpreter = null;

    public JPythonInterpreter() {
        interpreter = new PythonInterpreter();
    }
View Full Code Here

Examples of org.python.util.PythonInterpreter

*/
public class JPythonInterpreter implements org.apache.flex.forks.batik.script.Interpreter {
    private PythonInterpreter interpreter = null;

    public JPythonInterpreter() {
        interpreter = new PythonInterpreter();
    }
View Full Code Here

Examples of org.python.util.PythonInterpreter

                            // solve import statements.
                            PySystemState.add_extdir(jarDir);
                        }
                    }

                    PythonInterpreter interpreter = new PythonInterpreter();
                    interpreter.exec(script);
                    return null;
                }
            });
        } catch (PrivilegedActionException e) {
            logger.error(e.getMessage(), e);
View Full Code Here

Examples of org.python.util.PythonInterpreter

    public void registerFunctions(String path, String namespace, PigContext pigContext)
    throws IOException {
        Interpreter.setMain(false);
        Interpreter.init(path, pigContext);
        pigContext.addScriptJar(getJarPath(PythonInterpreter.class));
        PythonInterpreter pi = Interpreter.interpreter;
        @SuppressWarnings("unchecked")
        List<PyTuple> locals = ((PyStringMap) pi.getLocals()).items();
        namespace = (namespace == null) ? "" : namespace + NAMESPACE_SEPARATOR;
        try {
            for (PyTuple item : locals) {
                String key = (String) item.get(0);
                Object value = item.get(1);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.