[Geoserver-users] Run arbitrary Python scripts on GeoServer

2017-08-31 Thread Alex Chen via Geoserver-users

I need to create a Web Processing service on GeoServer (2.11.2) that triggers a 
back-end Python script. This script should be able to utilize requests and 
other packages necessary to do the job.

I have got the wps extension and all necessary GeoScript plugins installed with 
GeoServer.

I followed an example as below to create a custom script that can be called 
from the Admin Web Console WPS Request Builder.

http://suite.opengeo.org/opengeo-docs/processing/scripting/processcreate.html
import math, sys
from geoserver.wps import process
from geoscript.geom import Point
from geoscript.feature import Feature
from geoscript.layer import Layer

@process(
  title = 'Distance and Bearing',
  description = 'Computes Cartesian distance and bearing from features to an 
origin.' + str(sys.executable),
  inputs = {
'origin': (Point, 'Origin from which to calculate distance and bearing.'), 
'features': (Layer, 'Features to which distance and bearing should be 
calculated.')
  },
  outputs = {
'result': (Layer, 'Features with calculated distance and bearing 
attributes.')
  }
)
def run(origin, features):

  for f in features.features():
p = f.geom.centroid
d = p.distance(origin)
b = 90 - math.degrees(math.atan2(p.y - origin.y, p.x - origin.x))

yield Feature({'point': p, 'distance': d, 'bearing': b})
I tried to use Python's sys library and print out sys.executable as a testing 
process, but the output was NoneType.

I also tried to import requests but the GeoServer logs showed requests cannot 
be found.

I am wondering whether arbitrary Python packages e.g. Requests can be used in a 
script as such supported by GeoServer WPS. Are there any limitations for Python 
scripts that can be triggered as Web Processing Service by GeoServer?
Thanks!--
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

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users


Re: [Geoserver-users] Monitor-hibernate-plugin JARs breaking Geofence hibernate; Geoserver not starting

2017-08-31 Thread Steve Omondi
Thanks for the info Niels.  now I can confidently adjust my plan. I'll
share any further findings.

Regards,
Steve Ochieng

On Aug 31, 2017 16:37, "Niels Charlier"  wrote:

> Hey,
>
> This won't work, I have tried it before. Monitoring-hibernate won't even
> compile if you use the same version of hibernate that geofence uses.
> Unfortunately the library will need to be patched to become compatible
> with geofence-server.
>
> Kind Regards
> Niels
>
> On 31-08-17 14:27, Nuno Oliveira wrote:
>
> Hi,
>
> Thanks for the confirmation, so if monitoring plugin is working some of
> this libs need to be upgraded.
>
> In your case you can do the following, remove the hibernate libraries of
> one of the plugins. The
> versions are so close that without the class path clash things will
> probably work just fine. If you are
> building the plugin by your self you may just want o create a fat JAR that
> will shade the hibernate
> libraries an include them on the fat JAR.
>
> A word of caution, all the solutions above are just *temporary solutions*
> and should no be pushed to
> production without being carefully tested. The correct solution here is to
> equalize the hibernate
> dependencies of the two plugins (this is why dependencies should be
> declared on GeoServer
> main pom.xml dependency management so this issue can be avoided). The
> current hibernate
> upgrade will (probably) do that for you.
>
> Regarding the ELK (Elasticsearch, Losgstash and Kibana) stack [1] is a
> solution that is specially useful
> when you need to aggregate the logs o several GeoServers a visualize them
> on some unified UI.
>
> Regards,
>
> Nuno Oliveira
>
> [1] https://www.elastic.co/fr/webinars/introduction-elk-stack
>
> On 08/31/2017 07:01 AM, Steve Omondi wrote:
>
> Hi Nuno,
>
> You mentioned ELK stack, how do you use these to visualize and analyze
> the monitor data. Especially, I'd like to persist the data somehow so I can
> reuse the data.
>
> Could you point me to some simple and perhaps free tool for this. Thanks
>
> Kind regards,
> Steve Omondi
>
> On Thu, Aug 31, 2017 at 8:29 AM, Steve Omondi 
> wrote:
>
>> Hi Nuno,
>>
>> The second case is correct.
>>
>> I have monitor-hibernate working as expected in one instance of geoserver
>> without Geofence and correctly persisting monitoring data in a Postgis db.
>> I also have Geofence  (embedded) also working as expected in another
>> instance of geoserver without monitor hibernate.
>>
>> I have looked at the common .JARS from the two and there versions are
>> different in almost all of them.
>>
>> I will reproduce the Error logs and share here.
>>
>> Kind regards,
>> Steve Omondi
>>
>> On Wed, Aug 30, 2017 at 5:53 PM, Nuno Oliveira <
>> nuno.olive...@geo-solutions.it> wrote:
>>
>>> Hi Steve,
>>> I saw your mail in the *[Geoserver-devel] upgrade geofence hibernate*
>>> thread,
>>> I'm answering here because there is one thing you may want to check
>>> first.
>>>
>>> Is the monitor-hibernate-plugin actually working ? I have in mind that
>>> the last
>>> time I try it it was  actually not working ... typically I store the
>>> audit files in the
>>> file system and use an ELK stack or something similar to handle them.
>>>
>>> That say, if the monitor-hibernate-plugin is working as expected but is
>>> using
>>> a different version of hibernate non compatible with the version used by
>>> GeoFence ... well one of this modules will need to be upgraded.
>>>
>>> Can you share with the ML the output log show when GeoServer doesn't
>>> starts ?
>>>
>>> Regards,
>>>
>>>
>>> On 08/28/2017 08:24 AM, Steve Omondi wrote:
>>>
>>> Hey guys,
>>>
>>> I have Geofence Embedded working in Geoserver-2.11.2 and when I install
>>> monitor-hibernate-plugin Geofence is broken and Geoserver doesn't start.
>>>
>>> I need the Monitoring plugin to work with External Postgis database as
>>> well as Geofence internal server?
>>>
>>> How can I make sure these two work in harmony. So far I think the .jar
>>> files in the two are of different versions which is causing problems. I
>>> need a solution for this.
>>>
>>>
>>> Kind regards,
>>> Steve Omondi
>>>
>>>
>>> 
>>>  Virus-free.
>>> www.avast.com
>>> 
>>>
>>>
>>> --
>>> 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: 
>>> htt

Re: [Geoserver-users] Monitor-hibernate-plugin JARs breaking Geofence hibernate; Geoserver not starting

2017-08-31 Thread Nuno Oliveira

Ah! thanks for the info Niels, well I guess that upgrading is the only solution 
then :)

On 08/31/2017 02:36 PM, Niels Charlier wrote:

Hey,

This won't work, I have tried it before. Monitoring-hibernate won't even 
compile if you use the same version of hibernate that geofence uses.
Unfortunately the library will need to be patched to become compatible with 
geofence-server.

Kind Regards
Niels

On 31-08-17 14:27, Nuno Oliveira wrote:

Hi,

Thanks for the confirmation, so if monitoring plugin is working some of this 
libs need to be upgraded.

In your case you can do the following, remove the hibernate libraries of one of 
the plugins. The
versions are so close that without the class path clash things will probably 
work just fine. If you are
building the plugin by your self you may just want o create a fat JAR that will 
shade the hibernate
libraries an include them on the fat JAR.

A word of caution, all the solutions above are just *temporary solutions* and 
should no be pushed to
production without being carefully tested. The correct solution here is to 
equalize the hibernate
dependencies of the two plugins (this is why dependencies should be declared on 
GeoServer
main pom.xml dependency management so this issue can be avoided). The current 
hibernate
upgrade will (probably) do that for you.

Regarding the ELK (Elasticsearch, Losgstash and Kibana) stack [1] is a solution 
that is specially useful
when you need to aggregate the logs o several GeoServers a visualize them on 
some unified UI.

Regards,

Nuno Oliveira

[1] https://www.elastic.co/fr/webinars/introduction-elk-stack

On 08/31/2017 07:01 AM, Steve Omondi wrote:

Hi Nuno,

You mentioned ELK stack, how do you use these to visualize and analyze the 
monitor data. Especially, I'd like to persist the data somehow so I can reuse 
the data.

Could you point me to some simple and perhaps free tool for this. Thanks

Kind regards,
Steve Omondi

On Thu, Aug 31, 2017 at 8:29 AM, Steve Omondi mailto:steve.omo...@ramani.co.ke>> wrote:

Hi Nuno,

The second case is correct.

I have monitor-hibernate working as expected in one instance of geoserver 
without Geofence and correctly persisting monitoring data in a Postgis db. I 
also have Geofence  (embedded) also working as expected in another instance of 
geoserver without monitor hibernate.

I have looked at the common .JARS from the two and there versions are 
different in almost all of them.

I will reproduce the Error logs and share here.

Kind regards,
Steve Omondi

On Wed, Aug 30, 2017 at 5:53 PM, Nuno Oliveira mailto:nuno.olive...@geo-solutions.it>> wrote:

Hi Steve,
I saw your mail in the /[Geoserver-devel] upgrade geofence hibernate/ 
thread,
I'm answering here because there is one thing you may want to check 
first.

Is the monitor-hibernate-plugin actually working ? I have in mind that 
the last
time I try it it was  actually not working ... typically I store the 
audit files in the
file system and use an ELK stack or something similar to handle them.

That say, if the monitor-hibernate-plugin is working as expected but is 
using
a different version of hibernate non compatible with the version used by
GeoFence ... well one of this modules will need to be upgraded.

Can you share with the ML the output log show when GeoServer doesn't 
starts ?

Regards,


On 08/28/2017 08:24 AM, Steve Omondi wrote:

Hey guys,

I have Geofence Embedded working in Geoserver-2.11.2 and when I install 
monitor-hibernate-plugin Geofence is broken and Geoserver doesn't start.

I need the Monitoring plugin to work with External Postgis database as 
well as Geofence internal server?

How can I make sure these two work in harmony. So far I think the .jar 
files in the two are of different versions which is causing problems. I need a 
solution for this.


Kind regards,
Steve Omondi



   Virus-free. www.avast.com 





--
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 


Re: [Geoserver-users] Monitor-hibernate-plugin JARs breaking Geofence hibernate; Geoserver not starting

2017-08-31 Thread Niels Charlier

Hey,

This won't work, I have tried it before. Monitoring-hibernate won't even 
compile if you use the same version of hibernate that geofence uses.
Unfortunately the library will need to be patched to become compatible 
with geofence-server.


Kind Regards
Niels

On 31-08-17 14:27, Nuno Oliveira wrote:

Hi,

Thanks for the confirmation, so if monitoring plugin is working some 
of this libs need to be upgraded.


In your case you can do the following, remove the hibernate libraries 
of one of the plugins. The
versions are so close that without the class path clash things will 
probably work just fine. If you are
building the plugin by your self you may just want o create a fat JAR 
that will shade the hibernate

libraries an include them on the fat JAR.

A word of caution, all the solutions above are just *temporary 
solutions* and should no be pushed to
production without being carefully tested. The correct solution here 
is to equalize the hibernate
dependencies of the two plugins (this is why dependencies should be 
declared on GeoServer
main pom.xml dependency management so this issue can be avoided). The 
current hibernate

upgrade will (probably) do that for you.

Regarding the ELK (Elasticsearch, Losgstash and Kibana) stack [1] is a 
solution that is specially useful
when you need to aggregate the logs o several GeoServers a visualize 
them on some unified UI.


Regards,

Nuno Oliveira

[1] https://www.elastic.co/fr/webinars/introduction-elk-stack

On 08/31/2017 07:01 AM, Steve Omondi wrote:

Hi Nuno,

You mentioned ELK stack, how do you use these to visualize and 
analyze the monitor data. Especially, I'd like to persist the data 
somehow so I can reuse the data.


Could you point me to some simple and perhaps free tool for this. Thanks

Kind regards,
Steve Omondi

On Thu, Aug 31, 2017 at 8:29 AM, Steve Omondi 
mailto:steve.omo...@ramani.co.ke>> wrote:


Hi Nuno,

The second case is correct.

I have monitor-hibernate working as expected in one instance of
geoserver without Geofence and correctly persisting monitoring
data in a Postgis db. I also have Geofence  (embedded) also
working as expected in another instance of geoserver without
monitor hibernate.

I have looked at the common .JARS from the two and there versions
are different in almost all of them.

I will reproduce the Error logs and share here.

Kind regards,
Steve Omondi

On Wed, Aug 30, 2017 at 5:53 PM, Nuno Oliveira
mailto:nuno.olive...@geo-solutions.it>> wrote:

Hi Steve,
I saw your mail in the /[Geoserver-devel] upgrade geofence
hibernate/ thread,
I'm answering here because there is one thing you may want to
check first.

Is the monitor-hibernate-plugin actually working ? I have in
mind that the last
time I try it it was  actually not working ... typically I
store the audit files in the
file system and use an ELK stack or something similar to
handle them.

That say, if the monitor-hibernate-plugin is working as
expected but is using
a different version of hibernate non compatible with the
version used by
GeoFence ... well one of this modules will need to be upgraded.

Can you share with the ML the output log show when GeoServer
doesn't starts ?

Regards,


On 08/28/2017 08:24 AM, Steve Omondi wrote:

Hey guys,

I have Geofence Embedded working in Geoserver-2.11.2 and
when I install monitor-hibernate-plugin Geofence is broken
and Geoserver doesn't start.

I need the Monitoring plugin to work with External Postgis
database as well as Geofence internal server?

How can I make sure these two work in harmony. So far I
think the .jar files in the two are of different versions
which is causing problems. I need a solution for this.


Kind regards,
Steve Omondi



Virus-free. www.avast.com







--
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

Re: [Geoserver-users] Monitor-hibernate-plugin JARs breaking Geofence hibernate; Geoserver not starting

2017-08-31 Thread Nuno Oliveira

Hi,

Thanks for the confirmation, so if monitoring plugin is working some of this 
libs need to be upgraded.

In your case you can do the following, remove the hibernate libraries of one of 
the plugins. The
versions are so close that without the class path clash things will probably 
work just fine. If you are
building the plugin by your self you may just want o create a fat JAR that will 
shade the hibernate
libraries an include them on the fat JAR.

A word of caution, all the solutions above are just *temporary solutions* and 
should no be pushed to
production without being carefully tested. The correct solution here is to 
equalize the hibernate
dependencies of the two plugins (this is why dependencies should be declared on 
GeoServer
main pom.xml dependency management so this issue can be avoided). The current 
hibernate
upgrade will (probably) do that for you.

Regarding the ELK (Elasticsearch, Losgstash and Kibana) stack [1] is a solution 
that is specially useful
when you need to aggregate the logs o several GeoServers a visualize them on 
some unified UI.

Regards,

Nuno Oliveira

[1] https://www.elastic.co/fr/webinars/introduction-elk-stack

On 08/31/2017 07:01 AM, Steve Omondi wrote:

Hi Nuno,

You mentioned ELK stack, how do you use these to visualize and analyze the 
monitor data. Especially, I'd like to persist the data somehow so I can reuse 
the data.

Could you point me to some simple and perhaps free tool for this. Thanks

Kind regards,
Steve Omondi

On Thu, Aug 31, 2017 at 8:29 AM, Steve Omondi mailto:steve.omo...@ramani.co.ke>> wrote:

Hi Nuno,

The second case is correct.

I have monitor-hibernate working as expected in one instance of geoserver 
without Geofence and correctly persisting monitoring data in a Postgis db. I 
also have Geofence  (embedded) also working as expected in another instance of 
geoserver without monitor hibernate.

I have looked at the common .JARS from the two and there versions are 
different in almost all of them.

I will reproduce the Error logs and share here.

Kind regards,
Steve Omondi

On Wed, Aug 30, 2017 at 5:53 PM, Nuno Oliveira mailto:nuno.olive...@geo-solutions.it>> wrote:

Hi Steve,
I saw your mail in the /[Geoserver-devel] upgrade geofence hibernate/ 
thread,
I'm answering here because there is one thing you may want to check 
first.

Is the monitor-hibernate-plugin actually working ? I have in mind that 
the last
time I try it it was  actually not working ... typically I store the 
audit files in the
file system and use an ELK stack or something similar to handle them.

That say, if the monitor-hibernate-plugin is working as expected but is 
using
a different version of hibernate non compatible with the version used by
GeoFence ... well one of this modules will need to be upgraded.

Can you share with the ML the output log show when GeoServer doesn't 
starts ?

Regards,


On 08/28/2017 08:24 AM, Steve Omondi wrote:

Hey guys,

I have Geofence Embedded working in Geoserver-2.11.2 and when I install 
monitor-hibernate-plugin Geofence is broken and Geoserver doesn't start.

I need the Monitoring plugin to work with External Postgis database as 
well as Geofence internal server?

How can I make sure these two work in harmony. So far I think the .jar 
files in the two are of different versions which is causing problems. I need a 
solution for this.


Kind regards,
Steve Omondi



   Virus-free. www.avast.com 





--
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 


Geoserver-users@lists.sourceforge.net 

https://lists.sourceforge.net/lists/listinfo/geoserver-users 



-- 
Regards,

Nuno Oliveira
==
GeoServer Professional Services from the experts! 
Visithttp://goo.gl/it488V  for more informati