Package org.python.util

Examples of org.python.util.PythonInterpreter


    if (this.status == SelectionStatus.UP_TO_DATE)
      return;
    evalColumns.clear();
    for (Entry<Row, Boolean> entry : this.selectedRowsCache.entrySet()) {
      Row key = entry.getKey();
      PythonInterpreter interpreter = new PythonInterpreter();
      try {
        entry.setValue(evaluatePythonExpression(key, getCompiledCode(pythonCode, interpreter), interpreter));
      }catch(IOException e) {
        entry.setValue(false);
      }
View Full Code Here


  private void populateSelection() {
    List<Table> tables = new ArrayList<Table>();
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    CloneTableUtils.getDatatable(worksheet.getDataTable(), workspace.getFactory().getHTable(hTableId), tables, SuperSelectionManager.DEFAULT_SELECTION);
    PythonInterpreter interpreter = new PythonInterpreter();
    PyCode code = null;
    try {
      code = getCompiledCode(pythonCode, interpreter);
    } catch(Exception e) {
     
View Full Code Here

               // Give the application some time to launch before we start burning the cpu.
               Thread.sleep(2000);
            }
            catch (InterruptedException e)
            {}
            new PythonInterpreter();
         }
      };
      thread.setDaemon(true);
      thread.setPriority(Thread.MIN_PRIORITY);
      thread.start();
View Full Code Here

    * @return true if the script evaluated successfully, false if an error
    *         occurred while interpreting the script.
    */
   public boolean evalScript(boolean displayError)
   {
      final PythonInterpreter interp = this.getInitializedInterpreter();
      this.currentInterpreter = interp;
      try
      {
         interp.exec(this.textArea.getText());
      }
      catch (Exception e)
      {
         if (displayError)
         {
View Full Code Here

    * and the maze model variable.
    * @return A new interpreter.
    */
   private PythonInterpreter getInitializedInterpreter()
   {
      final PythonInterpreter interp = new PythonInterpreter();
      interp.exec("from maze.ai import RobotStep");
      interp.exec("from maze.model import Direction, MazeCell");
      interp.set("Forward", RobotStep.MoveForward);
      interp.set("Back", RobotStep.MoveBackward);
      interp.set("Left", RobotStep.RotateLeft);
      interp.set("Right", RobotStep.RotateRight);
      //We create and set a dummy maze variable so the user can analyze its methods.
      interp.set(ROBOT_MODEL_VAR_NAME, new RobotModel(new RobotModelMaster(new MazeModel(),
                                                                           MazeCell.valueOf(1, 16),
                                                                           Direction.North)));
      return interp;
   }
View Full Code Here

         return selectedText;
   }

   private String getVariableType(String variableName)
   {
      final PythonInterpreter interp = this.getCurrentInterpreter();
      PyObject selectedObj = interp.get(variableName);
      if (selectedObj != null)

         return selectedObj.getType().toString();
      else
         return "Unknown";
View Full Code Here

         return "Unknown";
   }

   private String getVariableValue(String variableName)
   {
      final PythonInterpreter interp = this.getCurrentInterpreter();
      PyObject selectedObj = interp.get(variableName);
      if (selectedObj != null)

         return selectedObj.toString();
      else
         return "Unknown";
View Full Code Here

   private void updateMethodsList(String selectedToken)
   {
      try
      {
         final PythonInterpreter interp = this.getCurrentInterpreter();
         PyObject obj = interp.eval("dir(" + selectedToken + ")");
         PyList pyList = (PyList) obj;
         final ScriptInfoPanel info = ScriptInfoPanel.getInstance();
         info.getListModel().clear();
         for (Object o : pyList)
         {
View Full Code Here

      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 {
View Full Code Here

    {
        File protonScriptFile = getPythonTestScript();
        String parentDirectory = protonScriptFile.getParent();
        String xmlReportFile = getOptionalXmlReportFilename();

        PythonInterpreter interp = createInterpreterWithArgs(xmlReportFile);

        LOGGER.info("About to call Jython test script: " + protonScriptFile + " with parent directory added to Jython path");

        interp.exec(
        "import sys\n"+
        "sys.path.insert(0,\""+parentDirectory+"\")\n"
        );

        try
        {
            String protonTestPyPath = protonScriptFile.getAbsolutePath();
            interp.execfile(protonTestPyPath);
        }
        catch (PyException e)
        {
            if( e.type.toString().equals("<type 'exceptions.SystemExit'>") && e.value.toString().equals("0") )
            {
View Full Code Here

TOP

Related Classes of org.python.util.PythonInterpreter

Copyright © 2018 www.massapicom. 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.