johnhuang-cn / jpserve Goto Github PK
View Code? Open in Web Editor NEWCalling Python from JAVA
License: MIT License
Calling Python from JAVA
License: MIT License
in jpserve.py code, at line number 38, replace socketserver with SocketServer. Also, at line number 204, replace, ThreadingTCPServer.init(self, server_address, RequestHandlerClass) with,
ForkingTCPServer.init(self, server_address, RequestHandlerClass)
@johnhuang-cn when I tried to call from jpserve.jpserve import JPServe. Spider gives me the following error:
from jpserve.jpserve import JPServe
Traceback (most recent call last):
File "", line 1, in
from jpserve.jpserve import JPServe
File "C:\ProgramData\Anaconda3\lib\site-packages\jpserve_init_.py", line 1, in
from .jpserve import JPServe
File "C:\ProgramData\Anaconda3\lib\site-packages\jpserve\jpserve.py", line 38, in
from socketserver import StreamRequestHandler, ThreadingTCPServer, ForkingTCPServer
ImportError: cannot import name 'ForkingTCPServer'
Can you help me?
Hi John ,
I have been trying with with python - spring boot using Jython 2.7 , for a simple py file it worked , but my python files are using requests module as they fetching data from another application via Rest client . and output data was so huge i have use the python script. The code that i have got as sample is require to download the module manually but requests module have so many problem and never complied properly when added in resources folder of project ( spring) i tried other module works ok like json . I tried setting path for interpreter to jyhon lib folder but its just not compile the request module. Do you have suggestion pls ? even if not definite answers but something to explorer , i am stuck for almost a week now. most of my python file are like this :
import requests
from requests.auth import HTTPBasicAuth
user1= "rajnibh[email protected]"
password = "*********"
baseurl = "https://central.oursecure.cloud:9440/api/nutanix/v3"
urlPost = "https://central.oursecure.cloud:9440/API/nutanix/v3/clusters/list"
method="POST"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
payload = {"length": 500}
def urlreq(url, verb, auth, user, passwd, params, verify, headers):
data = {
"kind": "cluster",
"sort_order": "ASCENDING",
"sort_attribute": "name"
}
print (url)
response = requests.post(url=url, data=data,auth=HTTPBasicAuth(user1,password))
return response
def getClusterList(url, method, user, password, headers, payload=None):
r = urlreq(url, verb=method, auth="BASIC", user=user1, passwd=password, params=payload, verify=False,
headers=headers)
return r
r = getClusterList(urlPost, method, user1, password, headers, json.dumps(payload))
if r.status_code == 401:
print("Response Status: " + str(r.status_code))
Can JPServe work with PySpark? When i use SparkSession And SqlContext it gives me error SqlContext is not defined. While when i run the script normally without jpserve is it working.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.