Ignore:
Timestamp:
Apr 11, 2020, 4:46:15 PM (7 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, master
Children:
3db3d13
Parents:
da2be70
Message:
  • Added yapf style config (src/python-style.yapf)
    • Updated all files to the yapf formatted version
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mapservice/server_impl/Config.py

    rda2be70 r7be94aa  
    2121import yaml
    2222
     23
    2324def 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
     25    config_from_file = yaml.safe_load(open(config_file))
     26    config = Config()
     27
     28    for entry in config_from_file:
     29        setattr(config, entry, config_from_file[entry])
     30
     31    return config
     32
    3133
    3234class 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
     35    DEBUG = False
     36    TESTING = False
     37    CREATE_TEST_DATABASE = False
     38    SQLALCHEMY_TRACK_MODIFICATIONS = False
     39    MAIL_SERVER = 'localhost'
     40    MAIL_PORT = 25
     41    MAIL_DEFAULT_SENDER = 'GNUBoat Mapservice <gnuboat@engsas.de>'
     42    MAPSERVICE_WEBCLIENT = '/'
     43    CELERY_BROKER_URL = 'pyamqp://guest@localhost//'
     44    CELERY_IMPORTS = ("gnuboat_mapservice.server_impl.tasks")
     45    CELERY_RESULT_BACKEND = "cache"
     46    CELERY_CACHE_BACKEND = 'memcached://127.0.0.1:11211'
     47    # pixel size of tiles to be generated
     48    TILES_SIZES = [256, 512]
     49    # Min required data points to get no nodata value in a raster pixel
     50    TILES_DENSITIES = [10, 100]
     51    TILES_DENSITY_BASEE = 100
     52    # How many years are data points allowed to be old, before they are excluded from calculations
     53    TILES_POINT_AGE_MAX = 10
     54    # 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).
     55    # Those zoomlevels are not rendered by log_process(), because they contain few details, but large areas
     56    TILES_ZOOM_RANGE = {'minimum': 10, 'maximum': 19}
     57    # schedule, when to run the job to generate tiles for low zoomlevels (0 - TILES_ZOOM_RANGE['minimum']),
     58    # As format see https://docs.celeryproject.org/en/stable/userguide/periodic-tasks.html#crontab-schedules
     59    # If TILES_ZOOM_RANGE['minimum'] = 10 it might need up to 4097 slice jobs per tile_size and density
     60    TILES_LITTLE_ZOOM_SCHEDULE = crontab(
     61        0, 0, day_of_month='2'
     62    )  # execute every second day of each month
     63    TILES_SKIP_EMPTY = True
     64    # Maximum size of the raster files generated during tile process in bits
     65    TILES_RASTER_FILE_SIZE_MAX = 512 * 1024 * 1024 * 8
     66
    6267
    6368class ProductionConfig(Config):
    64         SQLALCHEMY_DATABASE_URI = 'mysql+mysqldb://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'
     69    SQLALCHEMY_DATABASE_URI = 'mysql+mysqldb://gnuboat:gnuboat@localhost/gnuboat_mapservice'
     70    # TEMPLATE_FOLDER could be used to use own templates residing in TEMPLATE_FOLDER
     71    TEMPLATE_FOLDER = '/usr/share/gnuboat/templates'
     72
    6773
    6874class 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]
     75    DEBUG = True
     76    CREATE_TEST_DATABASE = True
     77    SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/test.db'
     78    MAPSERVICE_WEBCLIENT = 'http://localhost:8081'
     79    #SERVER_NAME = 'gnuboat-mapservice:8080'
     80    HOST = 'localhost'
     81    SERVER_NAME = 'localhost:8080'
     82    TILES_CACHE_PATH = os.path.join(Path.home(), '.cache/gnuboat/tiles')
     83    TILES_SIZES = [256]
     84
    7885
    7986class TestingConfig(DevelopmentConfig):
    80         """
     87    """
    8188                Configuration for testing purposes only (like tox/nosetests)
    8289        """
    83         TESTING = True
    84         DEBUG = False
    85         CELERY_BROKER_URL = ''
    86         SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/gnuboat-ci-tests.db'
     90    TESTING = True
     91    DEBUG = False
     92    CELERY_BROKER_URL = ''
     93    SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/gnuboat-ci-tests.db'
Note: See TracChangeset for help on using the changeset viewer.