Exemple #1
0
def create_and_save(root: gws.IRoot):
    cfg = create(root)

    if not cfg:
        force = root.application.var('server.mapproxy.forceStart')
        if force:
            gws.log.warn('mapproxy: no configuration, using default')
            cfg = DEFAULT_CONFIG
        else:
            gws.log.warn('mapproxy: no configuration, not starting')
            gws.lib.os2.unlink(CONFIG_PATH)
            return

    cfg_str = yaml.dump(cfg)

    # make sure the config is ok before starting the server!
    test_path = CONFIG_PATH + '.test.yaml'
    gws.write_file(test_path, cfg_str)

    try:
        make_wsgi_app(test_path)
    except Exception as e:
        raise gws.ConfigurationError(f'MAPPROXY ERROR: {e!r}') from e

    gws.lib.os2.unlink(test_path)

    # write into the real config path
    gws.write_file(CONFIG_PATH, cfg_str)
    def SvcDoRun(self):
        key=winreg.OpenKey(rootkey, subkey, 0, winreg.KEY_READ)
        port_to_bind=int(winreg.QueryValueEx(key, 'Port')[0])
        data_dir=str(winreg.QueryValueEx(key, 'DataDir')[0])
        app_config=data_dir + r'\mapproxy.yaml'
        log_conf=data_dir + r'\log.ini'

        cherrypy.config.update({
            'global':{
            'log.screen': False,
            'tools.log_tracebacks.on': True,
            'engine.autoreload.on': False,
            'engine.SIGHUP': None,
            'engine.SIGTERM': None
            }
        })
        
        fileConfig(log_conf, {'here': data_dir})
        application=make_wsgi_app(app_config)
        d=wsgiserver.WSGIPathInfoDispatcher({'/mapproxy': application})
        self.server=wsgiserver.CherryPyWSGIServer( (server_ip, port_to_bind), d, numthreads=10, server_name=None, max=-1, request_queue_size=2048, timeout=10, shutdown_timeout=5)
        # Infinite loop serving requests
        try:
            self.server.start()
        except Exception as e:
            # Log an error event
            servicemanager.LogErrorMsg("MapProxy failed to start:\n%s" % e)
Exemple #3
0
def serve_develop_command(args):
    parser = optparse.OptionParser("usage: %prog serve-develop [options] mapproxy.yaml")
    parser.add_option("-b", "--bind",
                      dest="address", default='127.0.0.1:8080',
                      help="Server socket [127.0.0.1:8080]. Use 0.0.0.0 for external access. :1234 to change port.")
    parser.add_option("--debug", default=False, action='store_true',
                      dest="debug",
                      help="Enable debug mode")
    options, args = parser.parse_args(args)

    if len(args) != 2:
        parser.print_help()
        print("\nERROR: MapProxy configuration required.")
        sys.exit(1)

    mapproxy_conf = args[1]

    host, port = parse_bind_address(options.address)

    if options.debug and host not in ('localhost', '127.0.0.1'):
        print(textwrap.dedent("""\
        ################# WARNING! ##################
        Running debug mode with non-localhost address
        is a serious security vulnerability.
        #############################################\
        """))


    if options.debug:
        setup_logging(level=logging.DEBUG)
    else:
        setup_logging()
    from mapproxy.wsgiapp import make_wsgi_app
    from mapproxy.config.loader import ConfigurationError
    from mapproxy.util.ext.serving import run_simple
    try:
        app = make_wsgi_app(mapproxy_conf, debug=options.debug)
    except ConfigurationError:
        sys.exit(2)

    extra_files = app.config_files.keys()

    if options.debug:
        try:
            from repoze.profile import ProfileMiddleware
            app = ProfileMiddleware(
               app,
               log_filename='/tmp/mapproxy_profile.log',
               discard_first_request=True,
               flush_at_shutdown=True,
               path='/__profile__',
               unwind=False,
            )
            print('Installed profiler at /__profile__')
        except ImportError:
            pass

    run_simple(host, port, app, use_reloader=True, processes=1,
        threaded=True, passthrough_errors=True,
        extra_files=extra_files)
Exemple #4
0
def serve_multiapp_develop_command(args):
    parser = optparse.OptionParser(
        "usage: %prog serve-multiapp-develop [options] projects/")
    parser.add_option("-b",
                      "--bind",
                      dest="address",
                      default='127.0.0.1:8080',
                      help="Server socket [127.0.0.1:8080]")
    options, args = parser.parse_args(args)

    if len(args) != 2:
        parser.print_help()
        print "\nERROR: MapProxy projects directory required."
        sys.exit(1)

    mapproxy_conf_dir = args[1]

    host, port = parse_bind_address(options.address)

    setup_logging()
    from mapproxy.multiapp import make_wsgi_app
    from mapproxy.util.ext.serving import run_simple
    app = make_wsgi_app(mapproxy_conf_dir)

    run_simple(host,
               port,
               app,
               use_reloader=True,
               processes=1,
               threaded=True,
               passthrough_errors=True)
Exemple #5
0
def serve_develop_command(args):
    parser = optparse.OptionParser("usage: %prog serve-develop [options] mapproxy.yaml")
    parser.add_option("-b", "--bind",
                      dest="address", default='127.0.0.1:8080',
                      help="Server socket [127.0.0.1:8080]. Use 0.0.0.0 for external access. :1234 to change port.")
    parser.add_option("--debug", default=False, action='store_true',
                      dest="debug",
                      help="Enable debug mode")
    options, args = parser.parse_args(args)

    if len(args) != 2:
        parser.print_help()
        print("\nERROR: MapProxy configuration required.")
        sys.exit(1)

    mapproxy_conf = args[1]

    host, port = parse_bind_address(options.address)

    if options.debug and host not in ('localhost', '127.0.0.1'):
        print(textwrap.dedent("""\
        ################# WARNING! ##################
        Running debug mode with non-localhost address
        is a serious security vulnerability.
        #############################################\
        """))


    if options.debug:
        setup_logging(level=logging.DEBUG)
    else:
        setup_logging()
    from mapproxy.wsgiapp import make_wsgi_app
    from mapproxy.config.loader import ConfigurationError
    from mapproxy.util.ext.serving import run_simple
    try:
        app = make_wsgi_app(mapproxy_conf, debug=options.debug)
    except ConfigurationError:
        sys.exit(2)

    extra_files = app.config_files.keys()

    if options.debug:
        try:
            from repoze.profile import ProfileMiddleware
            app = ProfileMiddleware(
               app,
               log_filename='/tmp/mapproxy_profile.log',
               discard_first_request=True,
               flush_at_shutdown=True,
               path='/__profile__',
               unwind=False,
            )
            print('Installed profiler at /__profile__')
        except ImportError:
            pass

    run_simple(host, port, app, use_reloader=True, processes=1,
        threaded=True, passthrough_errors=True,
        extra_files=extra_files)
Exemple #6
0
  def createProxy(self,changedOnly=False,isOffline=False):
    if self.mapproxy is None or self.configTimeStamp is None:
      changedOnly=False
    if not os.path.exists(self.configFile):
      self.mapproxy = None
      raise Exception("config file %s not found",self.configFile)
    st = os.stat(self.configFile)
    if changedOnly:
      if st.st_mtime == self.configTimeStamp:
        self.logger.debug("config file %s not changed",self.configFile)
        return False
    self.fatalError = None
    self.mapproxy = None
    self.configTimeStamp=st.st_mtime
    self.logger.log("creating mapproxy wsgi app with config %s", self.getConfigName(isOffline))
    try:
      self.createConfigAndMappings(isOffline)
      self.injector.checkCreatedIfNeeded(self.getConfigName(isOffline))
      self.mapproxy = make_wsgi_app(self.getConfigName(isOffline), ignore_config_warnings=True, reloader=False)
      self.getFatalError(True)
    except Exception as e:
      self.layerMappings={}
      self.logger.error("unable to create mapProxy: %s",traceback.format_exc())
      self.fatalError=str(e)
      raise

    self.logger.log("created mapproxy wsgi app")
    return True
Exemple #7
0
def serve_multiapp_develop_command(args):
    parser = optparse.OptionParser("usage: %prog serve-multiapp-develop [options] projects/")
    parser.add_option("-b", "--bind", dest="address", default="127.0.0.1:8080", help="Server socket [127.0.0.1:8080]")
    parser.add_option("--debug", default=False, action="store_true", dest="debug", help="Enable debug mode")
    options, args = parser.parse_args(args)

    if len(args) != 2:
        parser.print_help()
        print("\nERROR: MapProxy projects directory required.")
        sys.exit(1)

    mapproxy_conf_dir = args[1]

    host, port = parse_bind_address(options.address)

    if options.debug and host not in ("localhost", "127.0.0.1"):
        print(
            textwrap.dedent(
                """\
        ################# WARNING! ##################
        Running debug mode with non-localhost address
        is a serious security vulnerability.
        #############################################\
        """
            )
        )

    setup_logging()
    from mapproxy.multiapp import make_wsgi_app
    from mapproxy.util.ext.serving import run_simple

    app = make_wsgi_app(mapproxy_conf_dir, debug=options.debug)

    run_simple(host, port, app, use_reloader=True, processes=1, threaded=True, passthrough_errors=True)
Exemple #8
0
    def SvcDoRun(self):
        key = winreg.OpenKey(rootkey, subkey, 0, winreg.KEY_READ)
        port_to_bind = int(winreg.QueryValueEx(key, 'Port')[0])
        data_dir = str(winreg.QueryValueEx(key, 'DataDir')[0])
        app_config = data_dir + r'\mapproxy.yaml'
        log_conf = data_dir + r'\log.ini'

        cherrypy.config.update({
            'global': {
                'log.screen': False,
                'tools.log_tracebacks.on': True,
                'engine.autoreload.on': False,
                'engine.SIGHUP': None,
                'engine.SIGTERM': None
            }
        })

        fileConfig(log_conf, {'here': data_dir})
        application = make_wsgi_app(app_config)
        d = wsgiserver.WSGIPathInfoDispatcher({'/mapproxy': application})
        self.server = wsgiserver.CherryPyWSGIServer((server_ip, port_to_bind),
                                                    d,
                                                    numthreads=10,
                                                    server_name=None,
                                                    max=-1,
                                                    request_queue_size=2048,
                                                    timeout=10,
                                                    shutdown_timeout=5)
        # Infinite loop serving requests
        try:
            self.server.start()
        except Exception as e:
            # Log an error event
            servicemanager.LogErrorMsg("MapProxy failed to start:\n%s" % e)
Exemple #9
0
def serve_multiapp_develop_command(args):
    parser = optparse.OptionParser("usage: %prog serve-multiapp-develop [options] projects/")
    parser.add_option("-b", "--bind",
                      dest="address", default='127.0.0.1:8080',
                      help="Server socket [127.0.0.1:8080]")
    parser.add_option("--debug", default=False, action='store_true',
                      dest="debug",
                      help="Enable debug mode")
    options, args = parser.parse_args(args)

    if len(args) != 2:
        parser.print_help()
        print("\nERROR: MapProxy projects directory required.")
        sys.exit(1)

    mapproxy_conf_dir = args[1]

    host, port = parse_bind_address(options.address)

    if options.debug and host not in ('localhost', '127.0.0.1'):
        print(textwrap.dedent("""\
        ################# WARNING! ##################
        Running debug mode with non-localhost address
        is a serious security vulnerability.
        #############################################\
        """))

    setup_logging()
    from mapproxy.multiapp import make_wsgi_app
    from mapproxy.util.ext.serving import run_simple
    app = make_wsgi_app(mapproxy_conf_dir, debug=options.debug)

    run_simple(host, port, app, use_reloader=True, processes=1,
        threaded=True, passthrough_errors=True)
Exemple #10
0
def serve_develop_command(args):
    parser = optparse.OptionParser("usage: %prog serve-develop [options] mapproxy.yaml")
    parser.add_option(
        "-b",
        "--bind",
        dest="address",
        default="127.0.0.1:8080",
        help="Server socket [127.0.0.1:8080]. Use 0.0.0.0 for external access. :1234 to change port.",
    )
    parser.add_option("--debug", default=False, action="store_true", dest="debug", help="Enable debug mode")
    options, args = parser.parse_args(args)

    if len(args) != 2:
        parser.print_help()
        print("\nERROR: MapProxy configuration required.")
        sys.exit(1)

    mapproxy_conf = args[1]

    host, port = parse_bind_address(options.address)

    if options.debug and host not in ("localhost", "127.0.0.1"):
        print(
            textwrap.dedent(
                """\
        ################# WARNING! ##################
        Running debug mode with non-localhost address
        is a serious security vulnerability.
        #############################################\
        """
            )
        )

    if options.debug:
        setup_logging(level=logging.DEBUG)
    else:
        setup_logging()
    from mapproxy.wsgiapp import make_wsgi_app
    from mapproxy.config.loader import ConfigurationError
    from mapproxy.util.ext.serving import run_simple

    try:
        app = make_wsgi_app(mapproxy_conf, debug=options.debug)
    except ConfigurationError:
        sys.exit(2)

    run_simple(
        host,
        port,
        app,
        use_reloader=True,
        processes=1,
        threaded=True,
        passthrough_errors=True,
        extra_files=app.config_files.keys(),
    )
Exemple #11
0
    def add_mapproxy(self):
        mapproxy_config = self.config.get('SKYLINES_MAPPROXY')
        if not mapproxy_config:
            return

        from werkzeug.wsgi import DispatcherMiddleware
        import mapproxy.wsgiapp as mapproxy

        self.wsgi_app = DispatcherMiddleware(self.wsgi_app, {
            '/mapproxy': mapproxy.make_wsgi_app(mapproxy_config),
        })
Exemple #12
0
def serve_develop_command(args):
    parser = optparse.OptionParser(
        "usage: %prog serve-develop [options] mapproxy.yaml")
    parser.add_option("-b",
                      "--bind",
                      dest="address",
                      default='127.0.0.1:8080',
                      help="Server socket [127.0.0.1:8080]")
    parser.add_option("--debug",
                      default=False,
                      action='store_true',
                      dest="debug",
                      help="Enable debug mode")
    options, args = parser.parse_args(args)

    if len(args) != 2:
        parser.print_help()
        print("\nERROR: MapProxy configuration required.")
        sys.exit(1)

    mapproxy_conf = args[1]

    host, port = parse_bind_address(options.address)

    if options.debug and host not in ('localhost', '127.0.0.1'):
        print(
            textwrap.dedent("""\
        ################# WARNING! ##################
        Running debug mode with non-localhost address
        is a serious security vulnerability.
        #############################################\
        """))

    if options.debug:
        setup_logging(level=logging.DEBUG)
    else:
        setup_logging()
    from mapproxy.wsgiapp import make_wsgi_app
    from mapproxy.config.loader import ConfigurationError
    from mapproxy.util.ext.serving import run_simple
    try:
        app = make_wsgi_app(mapproxy_conf, debug=options.debug)
    except ConfigurationError:
        sys.exit(2)

    run_simple(host,
               port,
               app,
               use_reloader=True,
               processes=1,
               threaded=True,
               passthrough_errors=True,
               extra_files=app.config_files.keys())
 def SvcDoRun(self):
     key=winreg.OpenKey(rootkey, subkey, 0, winreg.KEY_READ)
     port_to_bind=int(winreg.QueryValueEx(key, 'Port')[0])
     data_dir=str(winreg.QueryValueEx(key, 'DataDir')[0])
     app_config=data_dir + r'\mapproxy.yaml'
     log_conf=data_dir + r'\log.ini'
     
     fileConfig(log_conf, {'here': data_dir})
     application=make_wsgi_app(app_config)
     d=wsgiserver.WSGIPathInfoDispatcher({'/mapproxy': application})
     self.server=wsgiserver.CherryPyWSGIServer( (server_ip, port_to_bind), d, numthreads=10, server_name=None, max=-1, request_queue_size=2048, timeout=10, shutdown_timeout=5)
     self.server.start()
Exemple #14
0
    def add_mapproxy(self):
        mapproxy_config = self.config.get('SKYLINES_MAPPROXY')
        if not mapproxy_config:
            return

        from werkzeug.wsgi import DispatcherMiddleware
        import mapproxy.wsgiapp as mapproxy

        self.wsgi_app = DispatcherMiddleware(
            self.wsgi_app, {
                '/mapproxy': mapproxy.make_wsgi_app(mapproxy_config),
            })
Exemple #15
0
def __ExtensionFactory__():
    ##    from paste.deploy import loadapp
    ##     from paste.script.util.logging_config import fileConfig

    # <INSTALLDIR>\config\mapproxy.yaml
    yaml_file = os.path.abspath(
        os.path.join(mapproxy_root_dir, r'config', r'mapproxy.yaml'))

    from mapproxy.wsgiapp import make_wsgi_app
    # application = make_wsgi_app(r'C:\mapproxy\mapproxy.yaml')
    application = make_wsgi_app(yaml_file)

    import isapi_wsgi
    return isapi_wsgi.ISAPIThreadPoolHandler(application)
Exemple #16
0
def mapproxy_thread(app_state):
    """Mapproxy background thread"""
    from mapproxy.wsgiapp import make_wsgi_app
    from geobox.lib.webserver import WebServerThread
    from geobox.utils import wait_for_http_server

    host = app_state.config.get('app', 'host')
    mapproxy_port = app_state.config.get('mapproxy', 'port')
    couch_port = app_state.config.get_int('couchdb', 'port')
    user_dir = app_state.user_data_path()

    # wait for up to ten seconds till couchdb is online
    wait_for_http_server('127.0.0.1', couch_port, max_wait=10)

    from geobox.lib.mapproxy import write_mapproxy_config
    write_mapproxy_config(app_state)

    app = make_wsgi_app(os.path.join(user_dir, 'mapproxy.yaml'), reloader=True)
    return WebServerThread(host, mapproxy_port, app, logger_name='geobox.mapproxy.server')
Exemple #17
0
def mapproxy_thread(app_state):
    """Mapproxy background thread"""
    from mapproxy.wsgiapp import make_wsgi_app
    from geobox.lib.webserver import WebServerThread
    from geobox.utils import wait_for_http_server

    host = app_state.config.get('app', 'host')
    mapproxy_port = app_state.config.get('mapproxy', 'port')
    couch_port = app_state.config.get_int('couchdb', 'port')
    user_dir = app_state.user_data_path()

    # wait for up to ten seconds till couchdb is online
    wait_for_http_server('127.0.0.1', couch_port, max_wait=10)

    from geobox.lib.mapproxy import write_mapproxy_config
    write_mapproxy_config(app_state)

    app = make_wsgi_app(os.path.join(user_dir, 'mapproxy.yaml'), reloader=True)
    return WebServerThread(host, mapproxy_port, app, logger_name='geobox.mapproxy.server')
Exemple #18
0
def serve_multiapp_develop_command(args):
    parser = optparse.OptionParser("usage: %prog serve-multiapp-develop [options] projects/")
    parser.add_option("-b", "--bind",
                      dest="address", default='127.0.0.1:8080',
                      help="Server socket [127.0.0.1:8080]")
    options, args = parser.parse_args(args)

    if len(args) != 2:
        parser.print_help()
        print "\nERROR: MapProxy projects directory required."
        sys.exit(1)

    mapproxy_conf_dir = args[1]

    host, port = parse_bind_address(options.address)

    setup_logging()
    from mapproxy.multiapp import make_wsgi_app
    from mapproxy.util.ext.serving import run_simple
    app = make_wsgi_app(mapproxy_conf_dir)

    run_simple(host, port, app, use_reloader=True, processes=1,
        threaded=True, passthrough_errors=True)
Exemple #19
0
def serve_develop_command(args):
    parser = optparse.OptionParser("usage: %prog serve-develop [options] mapproxy.yaml")
    parser.add_option("-b", "--bind",
                      dest="address", default='127.0.0.1:8080',
                      help="Server socket [127.0.0.1:8080]")
    parser.add_option("--debug", default=False, action='store_true',
                      dest="debug",
                      help="Enable debug mode")
    options, args = parser.parse_args(args)

    if len(args) != 2:
        parser.print_help()
        print "\nERROR: MapProxy configuration required."
        sys.exit(1)

    mapproxy_conf = args[1]

    host, port = parse_bind_address(options.address)

    if options.debug and host not in ('localhost', '127.0.0.1'):
        print textwrap.dedent("""\
        ################# WARNING! ##################
        Running debug mode with non-localhost address
        is a serious security vulnerability.
        #############################################\
        """)


    setup_logging()
    from mapproxy.wsgiapp import make_wsgi_app
    from mapproxy.config.loader import ConfigurationError
    from mapproxy.util.ext.serving import run_simple
    try:
        app = make_wsgi_app(mapproxy_conf, debug=options.debug)
    except ConfigurationError, ex:
        sys.exit(2)
import os
from mapproxy.wsgiapp import make_wsgi_app

config_file = os.path.join(
    os.path.dirname(os.path.abspath(__file__)), "mapproxy", "mapproxy.yaml"
)
application = make_wsgi_app(config_file)
Exemple #21
0
from gevent import pywsgi
from mapproxy.wsgiapp import make_wsgi_app

application = make_wsgi_app(r'/var/www/mapproxy/mapproxy.yaml')
server = pywsgi.WSGIServer(('', 8080), application)

server.serve_forever()
Exemple #22
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
### from logging.config import fileConfig
### import os.path
### fileConfig(r'/home/grahame/armchairantarcti.ca/limaproxy/log.ini', {'here': os.path.dirname(__file__)})

import os

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/app/limaproxy/mapproxy.yaml')
Exemple #23
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/var/mymapproxy/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/var/mymapproxy/katapang.yaml')
#application = make_wsgi_app(r'/var/mymapproxy/agm.yaml', reloader=True)
Exemple #24
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/var/mymapproxy/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/var/mymapproxy/solokanjeruk.yaml')
#application = make_wsgi_app(r'/var/mymapproxy/agm.yaml', reloader=True)
Exemple #25
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`

from logging.config import fileConfig
import os.path
fileConfig(r'/etc/qgisserver/qgismapproxy/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/etc/qgisserver/qgismapproxy/mapproxy.yaml', reloader=True)
Exemple #26
0
def make_app(port='', config=''):
    app = make_wsgi_app(config)  # Not sure how to specify port
    return app
Exemple #27
0
 def app(self, base_dir, config_file, additional_files):
     filename = base_dir.join(config_file)
     app = make_wsgi_app(filename.strpath, ignore_config_warnings=False)
     app.base_config.debug_mode = True
     return WSGITestApp(app, use_unicode=False)
Exemple #28
0
# https://mapproxy.org/docs/1.11.0/deployment.html?highlight=make_wsgi_app#server-script

import logging
import os

from mapproxy.wsgiapp import make_wsgi_app

import gws

logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)

cfg = gws.CONFIG_DIR + '/mapproxy.yaml'

if os.path.isfile(cfg):
    application = make_wsgi_app(cfg)

# import os, sys
# sys.path.append(os.path.dirname(os.path.realpath(__file__)))
# from util import AnnotationFilter
# application = AnnotationFilter(application)
else:
    import _winreg as winreg

# globals
rootkey=winreg.HKEY_LOCAL_MACHINE
subkey=r'SOFTWARE\COMPANY\APP\NUM'
server_ip='0.0.0.0'
        
if __name__ == '__main__':
    try:
        key=winreg.OpenKey(rootkey, subkey, 0, winreg.KEY_READ)
        port_to_bind=int(winreg.QueryValueEx(key, 'Port')[0])
        data_dir=str(winreg.QueryValueEx(key, 'DataDir')[0])
        app_config=data_dir + r'\mapproxy.yaml'
        log_conf=data_dir + r'\log.ini'        

        print ' MapProxy server running at http://localhost:' + str(port_to_bind) + '/mapproxy'
        print ' Close this dialog to stop the server' 

        fileConfig(log_conf, {'here': data_dir})
        application=make_wsgi_app(app_config)
        d=wsgiserver.WSGIPathInfoDispatcher({'/mapproxy': application})
        server=wsgiserver.CherryPyWSGIServer( (server_ip, port_to_bind), d, numthreads=10, server_name=None, max=-1, request_queue_size=2048, timeout=10, shutdown_timeout=5)
        
        server.start()
        
    except KeyboardInterrupt:
        server.stop()
    
    except Exception, e:
        print str(e)
Exemple #30
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/var/mymapproxy/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/var/mymapproxy/margaasih.yaml')
#application = make_wsgi_app(r'/var/mymapproxy/agm.yaml', reloader=True)
Exemple #31
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/vagrant/log.ini', {'here': os.path.dirname(__file__)})
import os
from mapproxy.wsgiapp import make_wsgi_app

ROOT = os.path.dirname(os.path.realpath(__file__))

YAML = os.path.join(ROOT, 'mapproxy.yaml')
application = make_wsgi_app(YAML)
#application = make_wsgi_app('/vagrant/proxy/mapproxy.yaml')
Exemple #32
0
from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app('data/mapproxy.yaml', reloader=True)
Exemple #33
0
#!/usr/bin/env python
#
# Wrapper script for launching MapProxy WSGI app.
#

import os
import sys
import argparse
from config import to_envvar

parser = argparse.ArgumentParser(description='Run the MapProxy WSGI app.')
parser.add_argument('config_file', nargs='?', metavar='mapproxy.yaml',
                    help='path to the configuration YAML file')
args = parser.parse_args()

if not to_envvar(args.config_file):
    parser.error('Config file "{}" not found.'.format(args.config_file))

sys.path.append(os.path.dirname(sys.argv[0]))

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(args.config_file)
Exemple #34
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/home/geonode/mapventure-mapproxy/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
# Change this to match the server running MapProxy
application = make_wsgi_app('/var/home/osm/mapventure-tools/MapProxy/mapproxy.yaml')
from mapproxy.wsgiapp import make_wsgi_app
from string import Template
import os

# render config template from environment variables

template_file = open('mapproxy.yaml.tmpl', 'r')
template = Template(template_file.read())
template_file.close()
output = template.substitute(wms_url=os.environ['WMS_URL'])

target_file = open('mapproxy.yaml', 'w')
target_file.write(output)
target_file.close()

application = make_wsgi_app('mapproxy.yaml')
Exemple #36
0
# WSGI module for use with Apache mod_wsgi or gunicorn

from logging.config import fileConfig
fileConfig(r'/srv/mapproxy/log.ini', {'here': '/srv/mapproxy/log'})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/srv/mapproxy/mapproxy.yaml')
Exemple #37
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/var/mymapproxy/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/var/mymapproxy/cileunyi.yaml')
#application = make_wsgi_app(r'/var/mymapproxy/agm.yaml', reloader=True)
Exemple #38
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/vagrant/log.ini', {'here': os.path.dirname(__file__)})
import os
from mapproxy.wsgiapp import make_wsgi_app

ROOT = os.path.dirname(os.path.realpath(__file__))

YAML = os.path.join(ROOT, "mapproxy.yaml")
application = make_wsgi_app(YAML)
# application = make_wsgi_app('/vagrant/proxy/mapproxy.yaml')
Exemple #39
0
# Wrapper script for launching MapProxy WSGI app.
#

import os
import sys
#import thread
import argparse
from config import to_envvar

parser = argparse.ArgumentParser(description='Run the MapProxy WSGI app.')
parser.add_argument('config_file', nargs='?', metavar='mapproxy.yaml',
                    help='path to the configuration YAML file')
parser.add_argument('--logfile', nargs='?', metavar='PATH',
                    help='path of the log file')
args = parser.parse_args()

if not to_envvar(args.config_file):
    parser.error('Config file "{}" not found.'.format(args.config_file))

# stderr doesn't work with FastCGI; the following is a hack to get a
# log file with diagnostics anyway
#if args.logfile:
#    sys.stderr = sys.stdout = file(args.logfile, 'a')

sys.path.append(os.path.dirname(sys.argv[0]))

#thread.stack_size(524288)

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(args.config_file)
Exemple #40
0
# -*- coding: utf-8 -*-

import os
from unittest import TestCase
from pyramid import testing
from webtest import TestApp
from mapproxy.wsgiapp import make_wsgi_app

from owslib.wmts import WebMapTileService


current = os.path.dirname(__file__)
config_uri = current.replace('chsdi/tests/integration', 'mapproxy/mapproxy.yaml')

app = make_wsgi_app(config_uri)


class TestsBase(TestCase):

    def setUp(self):
        self.testapp = TestApp(app)

    def tearDown(self):
        testing.tearDown()
        del self.testapp


class TestMapproxy(TestsBase):

    def test_wms_capabilities(self):
        resp = self.testapp.get('/service?REQUEST=GetCapabilities', status=200)
Exemple #41
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/var/mymapproxy/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/var/mymapproxy/ibun.yaml')
#application = make_wsgi_app(r'/var/mymapproxy/agm.yaml', reloader=True)
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/usr/local/mapproxy/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/usr/local/mapproxy/mapproxy-mapnik.yaml')
Exemple #43
0
def create_app(test_config):
    app = make_wsgi_app(test_config['config_file'], ignore_config_warnings=False)
    app.base_config.debug_mode = True
    test_config['app'] = TestApp(app, use_unicode=False)
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/home/lars/apps/merikarttagen/mapproxy/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/home/lars/apps/merikarttagen/mapproxy/merikartta.yaml')
Exemple #45
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/var/mymapproxy/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/var/mymapproxy/cimaung.yaml')
#application = make_wsgi_app(r'/var/mymapproxy/agm.yaml', reloader=True)
#!/usr/bin/python
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/home/lars/apps/merikarttagen/mapproxy/log.ini', {'here': os.path.dirname(__file__)})

import os
from mapproxy.wsgiapp import make_wsgi_app

path = os.path.dirname(os.path.realpath(__file__))

application = make_wsgi_app(path + r'/merikartta.yaml')
# WSGI module for use with Apache mod_wsgi or gunicorn

from logging.config import fileConfig
import os.path
fileConfig(r'/srv/mapproxy/etc/config/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/srv/mapproxy/etc/config/mapproxy.yaml')
Exemple #48
0
# WSGI module for use with uWSGI or gunicorn
from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app('/app/mapproxy.yaml')
Exemple #49
0
def create_app(test_config):
    app = make_wsgi_app(test_config['config_file'],
                        ignore_config_warnings=False)
    app.base_config.debug_mode = True
    test_config['app'] = TestApp(app, use_unicode=False)
Exemple #50
0
    line_y = 10
    for line in text:
        line_w, line_h = font.getsize(line)
        draw.text((10, line_y), line, font=font, fill=fill)
        line_y = line_y + line_h

    # Return a new ImageSource specifying the updated PIL image and
    # the image options from the original ImageSource
    return ImageSource(img, image.image_opts)


class RequestInfoFilter(object):
    """
    Simple MapProxy decorate_img middleware.

    Annotates map images with information about the request.
    """
    def __init__(self, app):
        self.app = app

    def __call__(self, environ, start_response):
        # Add the callback to the WSGI environment
        environ['mapproxy.decorate_img'] = annotate_img

        return self.app(environ, start_response)


# Make an WSGI application and wrap it in the middleware
application = RequestInfoFilter(make_wsgi_app(r'mapproxy.yaml'))
Exemple #51
0
# WSGI module for use with Apache mod_wsgi or gunicorn

# # uncomment the following lines for logging
# # create a log.ini with `mapproxy-util create -t log-ini`
# from logging.config import fileConfig
# import os.path
# fileConfig(r'/var/mymapproxy/log.ini', {'here': os.path.dirname(__file__)})

from mapproxy.wsgiapp import make_wsgi_app
application = make_wsgi_app(r'/var/mymapproxy/gununghalu.yaml')
#application = make_wsgi_app(r'/var/mymapproxy/agm.yaml', reloader=True)