Thanks Daniel so much!
I think I have an increased understanding of Jython in GeoServer. If I 
understand it correctly, there are two options to use 3rd party libraries in 
Python scripting given that both Java and Python implementations are available. 
One is to use Jython's easy_install or pip to install the packages similar to 
the way that the native Python equivalent does. The other way is to use the 
Java implementation (the jar file) and copy it to "... 
...\geoserver\WEB-INF\lib\". Either way, we can import the library in a Python 
script to be exposed as a custom App or WPS on GeoServer.
Cheers,Alex
    On Wednesday, 6 September 2017, 12:44:11 pm AEST, Daniel Baird 
<[email protected]> wrote:  
 
 On Wed, 6 Sep 2017 at 11:01 Alex Chen <[email protected]> wrote:

 Many thanks, Daniel & Tõnis, for both of your replies!
The GeoServer 2.11.2 uses Jython-2.5.0.jar that is saved in the "WEB-INF/lib".

I haven't tried this but I'd try getting easy_install by getting the python 
file from http://peak.telecommunity.com/dist/ez_setup.py, then running 
something like:
java -jar /whatever/path/WEB-INF/lib/Jython-2.5.0.jar ez-setup.py
..and doing the rest of a normal Python bootstrap into pip, but typing "java 
-jar /whatever/path/WEB-INF/lib/Jython-2.5.0.jar" instead of typing "python". 
Then remember to specify the path to Jython's verison of pip whenever you run 
pip, wherever that is.



[...]In terms of the "requests" package, I am still having trouble installing 
through pip or easy_install off the standalone Jython.

C:\jython2.7.0\bin>pip install requestsTraceback (most recent call last):  File 
"C:\jython2.7.0\Lib\runpy.py", line 161, in _run_module_as_main[...] 

    if file_uid != os.geteuid():
AttributeError: 'module' object has no attribute 'geteuid'
 Try updating pip as recommended here: 
https://stackoverflow.com/questions/30530976/how-to-install-selenium2library-for-robot-framework-using-pip-jython
 

 
- Daniel, you mentioned that "from Jython we can use Java networking 
libraries". Can you elaborate it in details please? How can I use 3rd Java libs 
in writing a GeoServer custom app or a web processing service in Python or 
JavaScript as I would like to stick with Python/JavaScript?


As long as the .class files are in your classpath, I think you can just use 
import to pull in Java library classes and use them: 
http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html Although 
if you normally write python, it's probably simpler to stick with whatever libs 
you're used to.

CheersDaniel  
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to