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)
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)
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)
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)
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(), )
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 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)
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) run_simple(host, port, app, use_reloader=True, processes=1, threaded=True, passthrough_errors=True, extra_files=[mapproxy_conf]) 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]
#############################################\ """) 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) run_simple(host, port, app, use_reloader=True, processes=1, threaded=True, passthrough_errors=True, extra_files=[mapproxy_conf]) 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)
def create_app(self, user, uuid): try: mapproxy_conf = self.config_cache.config( user, uuid, self.max_uuids_per_user) except RequestError: log.exception('unable to query config') return Response('service unavailable', status=503) if not mapproxy_conf: return Response('not found', status=404) log.debug('initializing project %s', mapproxy_conf) return make_mapproxy_wsgi_app(mapproxy_conf) def make_wsgi_app(config_cache_dir, max_age_seconds=30 * 60): cache = ConfigCache(config_cache_dir, max_age_seconds=max_age_seconds) app = WMSProxy(cache) return app if __name__ == '__main__': logging.basicConfig(level=logging.INFO) logging.getLogger('requests').setLevel(logging.WARN) app = make_wsgi_app('/tmp') from mapproxy.util.ext.serving import run_simple run_simple('localhost', 5050, app, use_reloader=True, processes=1, threaded=True, passthrough_errors=True)
return Response('not found', status=404) log.debug('initializing project %s', mapproxy_conf) return make_mapproxy_wsgi_app(mapproxy_conf) def make_wsgi_app(config_cache_dir, max_age_seconds=30 * 60, cartodb_domain='cartodb.com'): cache = ConfigCache(config_cache_dir, max_age_seconds=max_age_seconds, cartodb_domain=cartodb_domain) app = WMSProxy(cache) return app if __name__ == '__main__': logging.basicConfig(level=logging.INFO) logging.getLogger('requests').setLevel(logging.WARN) app = make_wsgi_app('/tmp') from mapproxy.util.ext.serving import run_simple run_simple('localhost', 5050, app, use_reloader=True, processes=1, threaded=True, passthrough_errors=True)