Skip to content

Commit

Permalink
- Version 2.14.x
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Sep 14, 2018
1 parent bfa507b commit 283ccca
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 218 deletions.
12 changes: 9 additions & 3 deletions .gitignore
@@ -1,8 +1,14 @@
*.py[cod]
*.suo

/build/
RemoteWPS1.pyproj
RemoteWPS1.sln
Include
Lib/
Scripts/
/Include
/Lib/
/Scripts/

/RemoteWPS.pyproj
/RemoteWPS.sln
/.vs/config/applicationhost.config
/dist/
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -33,7 +33,7 @@

setup(
name = "wps-remote",
version = "2.12.0",
version = "2.14.0",
author = "GeoServer Developers",
author_email = "geoserver-devel@lists.sourceforge.net",
description = "A library that allows users to publish their executables as GeoServer WPS Processes through the XMPP protocol",
Expand Down
105 changes: 0 additions & 105 deletions src/wps_remote.egg-info/PKG-INFO

This file was deleted.

52 changes: 0 additions & 52 deletions src/wps_remote.egg-info/SOURCES.txt

This file was deleted.

1 change: 0 additions & 1 deletion src/wps_remote.egg-info/dependency_links.txt

This file was deleted.

17 changes: 0 additions & 17 deletions src/wps_remote.egg-info/requires.txt

This file was deleted.

1 change: 0 additions & 1 deletion src/wps_remote.egg-info/top_level.txt

This file was deleted.

6 changes: 6 additions & 0 deletions src/wpsremote/processbot.py
Expand Up @@ -75,10 +75,16 @@ def __init__(self, remote_config_filepath, service_config_filepath, execute_mess

self._executable_path = serviceConfig.get("DEFAULT", "executable_path")
self._executable_cmd = serviceConfig.get("DEFAULT", "executable_cmd")
if not os.path.isabs(self._executable_path):
full_executable_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), self._executable_path)
self._executable_cmd = self._executable_cmd.replace(self._executable_path, full_executable_path)
self._executable_path = full_executable_path

self._stdout_parser = serviceConfig.get_list("Logging", "stdout_parser")
self._stdout_action = serviceConfig.get_list("Logging", "stdout_action")
self._output_dir = serviceConfig.get_path("DEFAULT", "output_dir")
if not os.path.isabs(self._output_dir):
self._output_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), self._output_dir)
self._max_running_time = datetime.timedelta(seconds = serviceConfig.getint("DEFAULT", "max_running_time_seconds"))

#create the concrete uploader object
Expand Down
1 change: 1 addition & 0 deletions src/wpsremote/resource_cleaner.py
Expand Up @@ -20,6 +20,7 @@
import logging
import traceback


class Resource(object):
"""
Identify a process generated by a remote WPS call.
Expand Down
46 changes: 25 additions & 21 deletions src/wpsremote/resource_monitor.py
Expand Up @@ -35,27 +35,31 @@ def __init__(self, load_average_scan_minutes):
ResourceMonitor.lock.release()

def proc_is_running(self, proc_names):
for proc in psutil.process_iter():

process = psutil.Process(proc.pid).as_dict() # Get the process info using PID

pid = str(process["pid"])
ppid = str(process["ppid"])
status = process["status"]

cpu_percent = process["cpu_percent"]
mem_percent = process["memory_percent"]

rss = str(process["memory_info"].rss)
vms = str(process["memory_info"].vms)
username = process["username"]
name = process["name"] # Here is the process name
path = process["cwd"]

for proc_name in proc_names:
if status.lower() == "running" and proc_name in name.lower():
return True

for proc in psutil.process_iter():
try:
process = psutil.Process(proc.pid).as_dict() # Get the process info using PID

pid = str(process["pid"])
ppid = str(process["ppid"])
status = process["status"]

cpu_percent = process["cpu_percent"]
mem_percent = process["memory_percent"]

rss = str(process["memory_info"].rss)
vms = str(process["memory_info"].vms)
username = process["username"]
name = process["name"] # Here is the process name
path = process["cwd"]

for proc_name in proc_names:
if status.lower() == "running" and proc_name in name.lower():
return True
except:
import traceback
tb = traceback.format_exc()
# print(tb)
continue
return False

def run(self):
Expand Down
2 changes: 1 addition & 1 deletion src/wpsremote/xmpp_data/configs/logger.properties
Expand Up @@ -30,7 +30,7 @@ interval=midnight
backupCount=5
formatter=simpleFormatter
level=DEBUG
args=('/share/xmpp_data/service.log',)
args=('./xmpp_data/service.log',)

[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
Expand Down
12 changes: 8 additions & 4 deletions src/wpsremote/xmpp_data/configs/myservice/code/test.py
Expand Up @@ -21,8 +21,9 @@
#id = os.urandom(10)
id = str(uuid.uuid4())
gdalContour = r'/usr/bin/gdal_contour'
src = r'/share/xmpp_data/resource_dir/srtm_39_04/srtm_39_04_c.tif'
dst = r'contour_'+id[:13]
src = '%s/../../../resource_dir/srtm_39_04/srtm_39_04_c.tif' % os.path.dirname(os.path.abspath(__file__))
trg = '%s/../../../output/%s.shp' % (os.path.dirname(os.path.abspath(__file__)), dst)
cmd = '-a elev' # just for example!
interval = '-i'

Expand All @@ -35,7 +36,7 @@ def __init__(self, args):

def run(self):
#fullCmd = ' '.join([gdalContour, cmd, self.youCanQuoteMe(src), self.youCanQuoteMe(dst), interval, self.args.interval])
fullCmd = ' '.join([gdalContour, cmd, src, self.args.workdir+'/'+dst+'.shp', interval, self.args.interval])
fullCmd = ' '.join([gdalContour, cmd, src, trg, interval, self.args.interval])
self.logger.debug("Running command > " + fullCmd)
proc=subprocess.Popen(fullCmd.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
for line in proc.stdout:
Expand All @@ -46,8 +47,11 @@ def run(self):
ret = proc.returncode

if (ret == 0):
zipf = zipfile.ZipFile(self.args.workdir+'/contour.zip', 'w')
self.zipdir(self.args.workdir+'/', zipf)
# zipf = zipfile.ZipFile(self.args.workdir+'/contour.zip', 'w')
# self.zipdir(self.args.workdir+'/', zipf)
output_dir = '%s/../../../output/' % os.path.dirname(os.path.abspath(__file__))
zipf = zipfile.ZipFile(output_dir+'/contour.zip', 'w')
self.zipdir(output_dir+'/', zipf)
zipf.close()

self.logger.info("ProgressInfo:100%")
Expand Down
Expand Up @@ -38,4 +38,4 @@ datefmt=

[formatter_consoleFormatter]
format=%(asctime)s [%(levelname)s] %(message)s
datefmt=
datefmt=
9 changes: 6 additions & 3 deletions src/wpsremote/xmpp_data/configs/myservice/service.config
Expand Up @@ -15,9 +15,9 @@
service = GdalContour
namespace = default
description = GDAL Contour Remote Service
executable_path = /share/xmpp_data/configs/myservice/code
executable_path = ./xmpp_data/configs/myservice/code
executable_cmd = python %(executable_path)s/test.py
output_dir = /share/xmpp_data/output/
output_dir = ./xmpp_data/output/
unique_execution_id = %(unique_exe_id)s
workdir = %(output_dir)s/%(unique_execution_id)s
active = True
Expand Down Expand Up @@ -74,6 +74,7 @@ template = -name value
[Output1]
name = result1
type = application/zip
output_mime_type = application/zip
description = WPS Resource Binary File
title = SRTM
filepath = %(workdir)s/contour.zip
Expand All @@ -98,6 +99,7 @@ publish_layer_name = contour
[Output2]
name = result2
type = application/x-netcdf
output_mime_type = application/x-netcdf
description = NetCDF Binary File
title = flexpart
filepath = %(output_dir)s/flexpart.nc
Expand All @@ -122,11 +124,12 @@ publish_layer_name = flexpart
[Output3]
name = result3
type = application/owc
output_mime_type = application/xml
description = WPS OWC Json MapContext
layers_to_publish = result2
publish_as_layer = true
publish_layer_name = owc_json_ctx
publish_metadata = /share/xmpp_data/resource_dir/owc_json_ctx.json
publish_metadata = ./xmpp_data/resource_dir/owc_json_ctx.json

# ########################################### #
# Logging Options Declaration #
Expand Down

0 comments on commit 283ccca

Please sign in to comment.