Package jep

Examples of jep.Jep



@Override
public Object execute(Map map, String userCodeLocation) throws Exception
   {
  Jep  jep=null;
 
  try{
    jep = new Jep(false);
    jep.setClassLoader(Thread.currentThread().getContextClassLoader());
    jep.set("map",map);
    jep.runScript(userCodeLocation);
   
  }
  catch (JepException e)
  {
    jep.close();
    e.printStackTrace();
    map.put("metadata", e.getMessage());
   
   }finally
   {
View Full Code Here


 
  @Override
  public  Object execute(Map params, String executorName) throws Exception
  {
    Jep  jep=null;
   
    try{
      jep = new Jep(false);
      jep.setClassLoader(Thread.currentThread().getContextClassLoader());
      jep.set("params",params);
      jep.runScript(executorName);
     
      jep.close();
      return params;
    }
    catch (JepException e)
    {
    //  jep.close();
View Full Code Here

  }


public static Object executeStatic(Map params, String executorName) throws Exception
   {
  Jep  jep=null;
 
  try{
    jep = new Jep(false);
    jep.setClassLoader(jep.getClass().getClassLoader());
    jep.set("params",params);
    jep.runScript(executorName);
   
  //  jep.close();
    return params;
  }
  catch (JepException e)
View Full Code Here


    public TacticServerStub() {
        try {

            jep = new Jep();

            ClassLoader loader = TacticServerStub.class.getClassLoader();
            String path = loader.getResource("tactic/TacticServerStub.class").toString();
            path = path.substring(5, path.length() );
            System.out.println(path);
View Full Code Here

    private Jep get_jep() {
        Thread thread = Thread.currentThread();
        Long thread_id = (Long) thread.getId();

        Jep jep = (Jep) jep_instances.get(thread_id);
        if (jep == null) {
            try {
                jep = new Jep();
                init(jep);
                jep_instances.put(thread_id, jep);

            } catch (JepException ex) {
                Logger.getLogger(TacticServerStub.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

        return thread_id;
    }


    private String execute(String function, Map kwargs) {
        Jep jep = get_jep();

        try {
            jep.set("function", function);


            // convert kwargs to a json string
            if (kwargs == null) {
                jep.set("kwargs", "{}");
            }
            else {
                Writer kwargs_writer = new StringWriter();
                mapper.writeValue(kwargs_writer, kwargs);
                String kwargs_json = kwargs_writer.toString();
                jep.set("kwargs", kwargs_json);
            }

            // execute the python script



            //jep.runScript("./delegator.py");
            jep.eval("delegate()");


            String ret_val = (String) jep.getValue("ret_val");
            return ret_val;
        } catch (jep.JepException e) {
            System.out.println("Error getting value from Jep");
            System.out.println(e);
        } catch (IOException e) {
View Full Code Here

    // Misc functions
    //
    public void set_project(String project_code) {
        if (protocol == "local") {
            try {
                Jep jep = get_jep();
                jep.eval("from pyasm.biz import Project");
                jep.eval("Project.set_project(\""+project_code+"\")");

            } catch (JepException ex) {
                Logger.getLogger(TacticServerStub.class.getName()).log(Level.SEVERE, null, ex);
            }
View Full Code Here

TOP

Related Classes of jep.Jep

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.