Coverage for gws-app/gws/gis/mpx/wsgi_app.py: 0%

29 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-17 01:37 +0200

1# https://mapproxy.org/docs/1.11.0/deployment.html?highlight=make_wsgi_app#server-script 

2 

3import yaml 

4 

5import gws 

6 

7import mapproxy.wsgiapp 

8import logging 

9 

10from . import config 

11 

12logging.basicConfig() 

13logging.getLogger().setLevel(logging.INFO) 

14 

15 

16# from mapproxy.wsgiapp, adapted to our needs 

17 

18def make_wsgi_app(services_conf=None, debug=False, ignore_config_warnings=True, reloader=False): 

19 conf = mapproxy.wsgiapp.load_configuration(mapproxy_conf=services_conf, ignore_warnings=ignore_config_warnings) 

20 services = conf.configured_services() 

21 

22 config_files = conf.config_files() 

23 conf.base_config.debug_mode = True 

24 

25 app = mapproxy.wsgiapp.MapProxyApp(services, conf.base_config) 

26 

27 app.config_files = config_files 

28 return app 

29 

30 

31mapproxy_app = make_wsgi_app(config.CONFIG_PATH) 

32 

33 

34def init(): 

35 cfg = yaml.safe_load(gws.u.read_file(config.CONFIG_PATH)) 

36 gws.u.ensure_dir(cfg['globals']['cache']['base_dir']) 

37 gws.u.ensure_dir(cfg['globals']['cache']['lock_dir']) 

38 gws.u.ensure_dir(cfg['globals']['cache']['tile_lock_dir']) 

39 

40 

41def application(environ, start_response): 

42 try: 

43 return mapproxy_app(environ, start_response) 

44 except Exception as exc: 

45 gws.log.exception() 

46 headers = [('Content-type', 'text/plain')] 

47 start_response('500', headers) 

48 return [('Exception\n' + repr(exc))] 

49 

50# import os, sys 

51# sys.path.append(os.path.dirname(os.path.realpath(__file__))) 

52# from util import AnnotationFilter 

53# application = AnnotationFilter(application)