Skip to content

Commit 48d4502

Browse files
committed
template config files - config/* files can be auto generate now by running generate_configs.py with templates given in config/templates/*
1 parent 1227c2d commit 48d4502

File tree

5 files changed

+173
-11
lines changed

5 files changed

+173
-11
lines changed

config/instances/testing.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
url: 'http://localhost:5000/wps'
2+
allowedinputpaths:
3+
- './static/'
4+
- 'd:\Maps'
5+
- 'd:\MRR'
6+
default_mimetype: 'text/xml'
7+
#default_mimetype: 'application/json'
8+
#json_indent: -1
9+
json_indent: 2
10+
11+
#root: './static/data/maps'
12+
root: 'd:\Maps'
13+
14+
dtm_color_palette: './static/data/color_files/color_file_1.txt'
15+
16+
dtm_geo: './static/data/maps/srtm1_x35_y32.tif'
17+
#dtm_geo: '@xlink:href=file:./static/data/maps/srtm1_x35_y32.tif'
18+
19+
dtm_utm: 'd:\maps\srtm3\utm\*.tif'
20+
#dtm_utm: './static/data/maps/srtm1_w84u36.tif'
21+
22+
radio_refractivity: 333.0
23+
radio_conductivity: 3.0
24+
radio_permittivity: 33.0
25+
radio_humidity: 33.0

config/pywps.cfg

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[metadata:main]
2-
identification_title=PyWPS Demo server
3-
identification_abstract=PyWPS testing and development server. Do NOT use this server in production environment. You shall setup PyWPS as WSGI application for production. Please refer documentation for further detials.
4-
identification_keywords=WPS,GRASS,PyWPS, Demo, Dev
2+
identification_title=TaLoS WPS server
3+
identification_abstract=TaLoS WPS server server.
4+
identification_keywords=WPS,GRASS,PyWPS,GDAL,Dev
55
identification_keywords_type=theme
66
identification_fees=None
77
identification_accessconstraints=None
8-
provider_name=PyWPS Developement team
9-
provider_url=http://pywps.org/
10-
contact_name=Your Name
8+
provider_name=TaLoS GIS Development team
9+
provider_url=https://github.com/talos-gis/pywps-flask
10+
contact_name=Idan Miara
1111
contact_position=Developer
1212
contact_address=My Street
1313
contact_city=My City
@@ -17,7 +17,7 @@ contact_country=World, Internet
1717
contact_phone=+00 00 11 22 33
1818
contact_fax=+00 99 88 77 66
1919
contact_email[email protected]
20-
contact_url=http://pywps.org
20+
contact_url=https://github.com/talos-gis
2121
contact_hours=8:00-20:00UTC
2222
contact_instructions=Knock on the door
2323
contact_role=pointOfContact
@@ -33,9 +33,9 @@ wd_inp_subdir=inputs
3333
wd_out_subdir=outputs
3434
maxprocesses=10
3535
parallelprocesses=-1
36-
allowedinputpaths=./static/;D:\Maps;m:\maps;d:\MRR
37-
;default_mimetype=application/json
38-
;json_indent=-1
36+
allowedinputpaths=./static/;d:\Maps;d:\MRR;
37+
default_mimetype=text/xml
38+
json_indent=2
3939

4040
[processing]
4141
mode=docker
@@ -53,4 +53,4 @@ format=%(asctime)s] [%(levelname)s] file=%(pathname)s line=%(lineno)s module=%(m
5353

5454

5555
[grass]
56-
gisbase=/usr/local/grass-7.3.svn/
56+
gisbase=/usr/local/grass-7.3.svn/
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
say_hello:
2+
name: "default-config"
3+
4+
ls:
5+
dir: '{{ root }}'
6+
pattern: '*.tif'
7+
8+
ras_val:
9+
r: '{{ dtm_geo }}'
10+
11+
crop_color:
12+
r: '{{ dtm_geo }}'
13+
of: 'czml'
14+
# color_palette: '{{ dtm_color_palette }}'
15+
16+
viewshed:
17+
r: '{{ dtm_utm }}'
18+
of: 'czml'
19+
in_crs: '0'
20+
out_crs: '0'
21+
backend: 'talos'
22+
23+
refractivity: {{ radio_refractivity }}
24+
conductivity: {{ radio_conductivity }}
25+
permittivity: {{ radio_permittivity }}
26+
humidity: {{ radio_humidity }}
27+
28+
fill_center: False
29+
profile_extension: True
30+
31+
tester:
32+
r: '{{ dtm_geo }}'
33+
name: 'Tester'
34+
35+
los:
36+
of: 'json'
37+
r: '{{ dtm_utm }}'
38+
in_crs: '0'
39+
out_crs: '0'
40+
backend: 'radio'
41+
42+
refractivity: {{ radio_refractivity }}
43+
conductivity: {{ radio_conductivity }}
44+
permittivity: {{ radio_permittivity }}
45+
humidity: {{ radio_humidity }}
46+
47+
fill_center: False
48+
profile_extension: True

config/templates/pywps.cfg

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[metadata:main]
2+
identification_title=TaLoS WPS server
3+
identification_abstract=TaLoS WPS server server.
4+
identification_keywords=WPS,GRASS,PyWPS,GDAL,Dev
5+
identification_keywords_type=theme
6+
identification_fees=None
7+
identification_accessconstraints=None
8+
provider_name=TaLoS GIS Development team
9+
provider_url=https://github.com/talos-gis/pywps-flask
10+
contact_name=Idan Miara
11+
contact_position=Developer
12+
contact_address=My Street
13+
contact_city=My City
14+
contact_stateorprovince=None
15+
contact_postalcode=000 00
16+
contact_country=World, Internet
17+
contact_phone=+00 00 11 22 33
18+
contact_fax=+00 99 88 77 66
19+
contact_email[email protected]
20+
contact_url=https://github.com/talos-gis
21+
contact_hours=8:00-20:00UTC
22+
contact_instructions=Knock on the door
23+
contact_role=pointOfContact
24+
25+
[server]
26+
maxsingleinputsize=1mb
27+
maxrequestsize=3mb
28+
url={{ url }}
29+
outputurl=outputs
30+
outputpath=outputs
31+
workdir=workdir
32+
wd_inp_subdir=inputs
33+
wd_out_subdir=outputs
34+
maxprocesses=10
35+
parallelprocesses=-1
36+
allowedinputpaths={% for path in allowedinputpaths %}{{path}};{% endfor %}
37+
default_mimetype={{ default_mimetype }}
38+
json_indent={{ json_indent }}
39+
40+
[processing]
41+
mode=docker
42+
port_min=5050
43+
port_max=5070
44+
docker_img=container
45+
dckr_inp_dir=/pywps-flask/data
46+
dckr_out_dir=/pywps-flask/outputs
47+
48+
[logging]
49+
level=INFO
50+
file=logs/pywps.log
51+
database=sqlite:///logs/pywps-logs.sqlite3
52+
format=%(asctime)s] [%(levelname)s] file=%(pathname)s line=%(lineno)s module=%(module)s function=%(funcName)s %(message)s
53+
54+
55+
[grass]
56+
gisbase=/usr/local/grass-7.3.svn/

generate_configs.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import jinja2
2+
import os
3+
from pathlib import Path
4+
import yaml
5+
6+
output_directory = Path('./config')
7+
template_root = Path('./config/templates')
8+
parameter_file = Path('./config/instances/testing.yaml')
9+
template_files = list(p.relative_to(template_root) for p in template_root.rglob('*.*'))
10+
11+
if os.path.exists(parameter_file):
12+
try:
13+
stream = open(parameter_file, 'r')
14+
parameter_dict = yaml.safe_load(stream)
15+
except Exception as err:
16+
raise Exception(f'Cannot process parameter file {parameter_file}')
17+
else:
18+
raise Exception(f'Parameter file {parameter_file} not found!')
19+
20+
if not os.path.exists(output_directory):
21+
os.mkdir(output_directory)
22+
23+
env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath=template_root))
24+
outputs = []
25+
for template_file in template_files:
26+
template = env.get_template(str(template_file))
27+
result = template.render(parameter_dict)
28+
output_file = output_directory / template_file
29+
outputs.append(output_file)
30+
f = open(output_file, "w")
31+
f.write(result)
32+
f.close()
33+
print(f'configs created: {outputs}')

0 commit comments

Comments
 (0)