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

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

Fixed mysql connection string

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[ea6eba1]1'''
[b83ac10]2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
[ea6eba1]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'''
[5e16955]17
18from celery.schedules import crontab
19from pathlib import Path
20import os
[096625e]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
[5e16955]31
[5e4cb73]32class Config(object):
33 DEBUG = False
34 TESTING = False
35 CREATE_TEST_DATABASE = False
36 SQLALCHEMY_TRACK_MODIFICATIONS = False
[bd0cb38]37 MAIL_SERVER = 'localhost'
38 MAIL_PORT = 25
39 MAIL_DEFAULT_SENDER = 'GNUBoat Mapservice <gnuboat@engsas.de>'
40 MAPSERVICE_WEBCLIENT = '/'
[a88607b]41 CELERY_BROKER_URL = 'pyamqp://guest@localhost//'
[adda9f2]42 CELERY_IMPORTS = ("gnuboat_mapservice.server_impl.tasks")
[c5ca247]43 CELERY_RESULT_BACKEND = "cache"
44 CELERY_CACHE_BACKEND = 'memcached://127.0.0.1:11211'
[5e16955]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}
[c5ca247]55 # schedule, when to run the job to generate tiles for low zoomlevels (0 - TILES_ZOOM_RANGE['minimum']),
[5e16955]56 # As format see https://docs.celeryproject.org/en/stable/userguide/periodic-tasks.html#crontab-schedules
[c5ca247]57 # If TILES_ZOOM_RANGE['minimum'] = 10 it might need up to 4097 slice jobs per tile_size and density
[ce301d3]58 TILES_LITTLE_ZOOM_SCHEDULE = crontab(0, 0, day_of_month='2') # execute every second day of each month
[c5ca247]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
[ea6eba1]62
[5e4cb73]63class ProductionConfig(Config):
[da2be70]64 SQLALCHEMY_DATABASE_URI = 'mysql+mysqldb://gnuboat:gnuboat@localhost/gnuboat_mapservice'
[5c9c247]65 # TEMPLATE_FOLDER could be used to use own templates residing in TEMPLATE_FOLDER
66 TEMPLATE_FOLDER='/usr/share/gnuboat/templates'
[ea6eba1]67
[5e4cb73]68class DevelopmentConfig(Config):
69 DEBUG = True
70 CREATE_TEST_DATABASE = True
[ae2ff15]71 SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/test.db'
[bd0cb38]72 MAPSERVICE_WEBCLIENT = 'http://localhost:8081'
[a88607b]73 #SERVER_NAME = 'gnuboat-mapservice:8080'
74 HOST = 'localhost'
75 SERVER_NAME = 'localhost:8080'
[5e16955]76 TILES_CACHE_PATH = os.path.join(Path.home(), '.cache/gnuboat/tiles')
77 TILES_SIZES = [256]
[5e4cb73]78
[5e16955]79class TestingConfig(DevelopmentConfig):
[be66b78]80 """
81 Configuration for testing purposes only (like tox/nosetests)
82 """
[5e4cb73]83 TESTING = True
[ae2ff15]84 DEBUG = False
[be66b78]85 CELERY_BROKER_URL = ''
[ae2ff15]86 SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/gnuboat-ci-tests.db'
Note: See TracBrowser for help on using the repository browser.