jpserve


Namejpserve JSON
Version 0.1.0 PyPI version JSON
download
home_page
Summaryjpserve: Calling Python from JAVA
upload_time
maintainer
docs_urlNone
authorJohn Huang
requires_pythonNone
license
keywords jpserve calling python from java
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            jpserve
""""""""""""""""""

Jpserve provides a simple and high performance way to execute Python script in JAVA. It includes PyServe and JClient API. 

* PyServe is an execute server running on Python side and listening the execute requests from JAVA.
* The JClient API can executes Python snippet or complete script file from java, it send the script to PyServe and get the execution result. The result is JSON format, so you can exchange the complex data between JAVA and Python flexibly.

Quick Start
""""""""""""""""""

Python Side
------------------

Open Python console, import magpie and start the PyServe:

>>> from magpie.pyserve import PyServe
>>> server = PyServe(("localhost", 8888))
>>> server.start()
>>>
    INFO:pserve:Magpie magpie starting...
    INFO:pserve:Magpie magpie listening in localhost 8888 
>>>


JAVA Side
------------------
>>>
// init the PyServeContext, it will make a connection to PyServe
PyServeContext.init("localhost", 8888);
// 
// prepare the script, and assign the return value to _result_
String script = "a = 2\n"
              + "b = 3\n"
              + "_result_ = a * b";
//
// sned the script to PyServe, it returns the final result
PyResult rs = executor.exec(s);
//
// check if the execution is success
if (rs.isSuccess()) {
  System.out.println("Result: " + rs.getResult()); // get the _result_ value
}
else {
  System.out.println("Execute python script failed: " + rs.getMsg());
}              
------------------------
Result: 6
            

Raw data

            {
    "_id": null,
    "maintainer": "",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": "",
    "cheesecake_code_kwalitee_id": null,
    "keywords": "jpserve, calling Python from Java",
    "author": "John Huang",
    "home_page": "",
    "download_url": "",
    "platform": "any",
    "version": "0.1.0",
    "cheesecake_documentation_id": null,
    "description": "jpserve\r\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\r\n\r\nJpserve provides a simple and high performance way to execute Python script in JAVA. It includes PyServe and JClient API. \r\n\r\n* PyServe is an execute server running on Python side and listening the execute requests from JAVA.\r\n* The JClient API can executes Python snippet or complete script file from java, it send the script to PyServe and get the execution result. The result is JSON format, so you can exchange the complex data between JAVA and Python flexibly.\r\n\r\nQuick Start\r\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\r\n\r\nPython Side\r\n------------------\r\n\r\nOpen Python console, import magpie and start the PyServe:\r\n\r\n>>> from magpie.pyserve import PyServe\r\n>>> server = PyServe((\"localhost\", 8888))\r\n>>> server.start()\r\n>>>\r\n    INFO:pserve:Magpie magpie starting...\r\n    INFO:pserve:Magpie magpie listening in localhost 8888 \r\n>>>\r\n\r\n\r\nJAVA Side\r\n------------------\r\n>>>\r\n// init the PyServeContext, it will make a connection to PyServe\r\nPyServeContext.init(\"localhost\", 8888);\r\n// \r\n// prepare the script, and assign the return value to _result_\r\nString script = \"a = 2\\n\"\r\n              + \"b = 3\\n\"\r\n              + \"_result_ = a * b\";\r\n//\r\n// sned the script to PyServe, it returns the final result\r\nPyResult rs = executor.exec(s);\r\n//\r\n// check if the execution is success\r\nif (rs.isSuccess()) {\r\n  System.out.println(\"Result: \" + rs.getResult()); // get the _result_ value\r\n}\r\nelse {\r\n  System.out.println(\"Execute python script failed: \" + rs.getMsg());\r\n}              \r\n------------------------\r\nResult: 6",
    "lcname": "jpserve",
    "name": "jpserve",
    "github": false,
    "bugtrack_url": "",
    "license": "",
    "summary": "jpserve: Calling Python from JAVA",
    "split_keywords": [
        "jpserve",
        " calling python from java"
    ],
    "author_email": "john.h.cn@gmail.com",
    "urls": [],
    "cheesecake_installability_id": null
}
        
Elapsed time: 0.04043s