source: src/mapservice/server_impl/Config.py@ ff880df

debian/bullseye
Last change on this file since ff880df was 5c9c247, checked in by Joachim Langenbach <joachim.langenbach@…>, 7 years ago

To find the template files, when started per installed package and per module from src-gen

  • Folder for templates is now set (in the descending priority)
    • per Config option TEMPLATE_FOLDER
    • per template_folder optional argument to setup_app(). The option is set by main.py (see mustache)

For tests the template_folder is set by init.py from test folder (s. inittest.mustache)

  • Property mode set to 100644
File size: 3.5 KB
Line 
1'''
2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16'''
17
18from celery.schedules import crontab
19from pathlib import Path
20import os
21import yaml
22
23def load_from_file(config_file):
24 config_from_file = yaml.safe_load(open(config_file))
25 config = Config()
26
27 for entry in config_from_file:
28 setattr(config, entry, config_from_file[entry])
29
30 return config
31
32class Config(object):
33 DEBUG = False
34 TESTING = False
35 CREATE_TEST_DATABASE = False
36 SQLALCHEMY_TRACK_MODIFICATIONS = False
37 MAIL_SERVER = 'localhost'
38 MAIL_PORT = 25
39 MAIL_DEFAULT_SENDER = 'GNUBoat Mapservice <gnuboat@engsas.de>'
40 MAPSERVICE_WEBCLIENT = '/'
41 CELERY_BROKER_URL = 'pyamqp://guest@localhost//'
42 CELERY_IMPORTS = ("gnuboat_mapservice.server_impl.tasks")
43 CELERY_RESULT_BACKEND = "cache"
44 CELERY_CACHE_BACKEND = 'memcached://127.0.0.1:11211'
45 # pixel size of tiles to be generated
46 TILES_SIZES = [256, 512]
47 # Min required data points to get no nodata value in a raster pixel
48 TILES_DENSITIES = [10, 100]
49 TILES_DENSITY_BASEE = 100
50 # How many years are data points allowed to be old, before they are excluded from calculations
51 TILES_POINT_AGE_MAX = 10
52 # log_process generates tiles for this zoom range. all lower zoomlevels (0 - x) are generated by a periodic task (s. TILES_LITTLE_ZOOM_SCHEDULE option).
53 # Those zoomlevels are not rendered by log_process(), because they contain few details, but large areas
54 TILES_ZOOM_RANGE = {'minimum': 10, 'maximum': 19}
55 # schedule, when to run the job to generate tiles for low zoomlevels (0 - TILES_ZOOM_RANGE['minimum']),
56 # As format see https://docs.celeryproject.org/en/stable/userguide/periodic-tasks.html#crontab-schedules
57 # If TILES_ZOOM_RANGE['minimum'] = 10 it might need up to 4097 slice jobs per tile_size and density
58 TILES_LITTLE_ZOOM_SCHEDULE = crontab(0, 0, day_of_month='2') # execute every second day of each month
59 TILES_SKIP_EMPTY = True
60 # Maximum size of the raster files generated during tile process in bits
61 TILES_RASTER_FILE_SIZE_MAX = 512 * 1024 * 1024 * 8
62
63class ProductionConfig(Config):
64 SQLALCHEMY_DATABASE_URI = 'mysql://gnuboat:gnuboat@localhost/gnuboat_mapservice'
65 # TEMPLATE_FOLDER could be used to use own templates residing in TEMPLATE_FOLDER
66 TEMPLATE_FOLDER='/usr/share/gnuboat/templates'
67
68class DevelopmentConfig(Config):
69 DEBUG = True
70 CREATE_TEST_DATABASE = True
71 SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/test.db'
72 MAPSERVICE_WEBCLIENT = 'http://localhost:8081'
73 #SERVER_NAME = 'gnuboat-mapservice:8080'
74 HOST = 'localhost'
75 SERVER_NAME = 'localhost:8080'
76 TILES_CACHE_PATH = os.path.join(Path.home(), '.cache/gnuboat/tiles')
77 TILES_SIZES = [256]
78
79class TestingConfig(DevelopmentConfig):
80 """
81 Configuration for testing purposes only (like tox/nosetests)
82 """
83 TESTING = True
84 DEBUG = False
85 CELERY_BROKER_URL = ''
86 SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/gnuboat-ci-tests.db'
Note: See TracBrowser for help on using the repository browser.