Exemplo n.º 1
0
def handler(event: dict, context: dict):
    path = event['path']
    for k, v in event['pathParams'].items():
        path = path.replace('{' + k + '}', v)
    if not path.endswith('/'):
        path += '/'
    event['path'] = path
    print(path)
    return handle_request(application, event, context)
Exemplo n.º 2
0
def lambda_handler(event, context):

    print(event)
    print(context)

    sk = os.getenv("SECRET_KEY", "FALSE")
    if sk is not "FALSE":
        game_play.app.server_key = sk
        game_play.app.config["SECRET_KEY"] = sk

    return serverless_wsgi.handle_request(game_play.app, event, context)
Exemplo n.º 3
0
def handle(event, context):
    try:
        logger.info("handling hub event", subhub_event=event, context=context)
        return serverless_wsgi.handle_request(hub_app.app, event, context)
    except Exception as e:  # pylint: disable=broad-except
        logger.exception("exception occurred",
                         subhub_event=event,
                         context=context,
                         error=e)
        # TODO: Add Sentry exception catch here
        raise
Exemplo n.º 4
0
def handle(event, context):
    try:
        return serverless_wsgi.handle_request(sub_app.app, event, context)
    except Exception as e:  # pylint: disable=broad-except
        logger.exception("exception occurred",
                         subhub_event=event,
                         context=context,
                         error=e)
        raise
    finally:
        logger.info("handling sub event", sub_event=event, context=context)
Exemplo n.º 5
0
def handler(event, context):
    """ Lambda event handler, invokes the WSGI wrapper and handles command invocation
    """
    if "_serverless-wsgi" in event:
        import shlex
        import subprocess
        from werkzeug._compat import StringIO, to_native

        native_stdout = sys.stdout
        native_stderr = sys.stderr
        output_buffer = StringIO()

        try:
            sys.stdout = output_buffer
            sys.stderr = output_buffer

            meta = event["_serverless-wsgi"]
            if meta.get("command") == "exec":
                # Evaluate Python code
                exec(meta.get("data", ""))
            elif meta.get("command") == "command":
                # Run shell commands
                result = subprocess.check_output(meta.get("data", ""),
                                                 shell=True,
                                                 stderr=subprocess.STDOUT)
                output_buffer.write(to_native(result))
            elif meta.get("command") == "manage":
                # Run Django management commands
                from django.core import management

                management.call_command(*shlex.split(meta.get("data", "")))
            elif meta.get("command") == "flask":
                # Run Flask CLI commands
                from flask.cli import ScriptInfo

                wsgi_app.cli.main(
                    shlex.split(meta.get("data", "")),
                    standalone_mode=False,
                    obj=ScriptInfo(create_app=_create_app),
                )
            else:
                raise Exception("Unknown command: {}".format(
                    meta.get("command")))
        except:  # noqa
            return traceback.format_exc()
        finally:
            sys.stdout = native_stdout
            sys.stderr = native_stderr

        return output_buffer.getvalue()
    else:
        return serverless_wsgi.handle_request(wsgi_app, event, context)
def handler(event, context):
    """Lambda event handler, invokes the WSGI wrapper and handles command invocation"""
    if "_serverless-wsgi" in event:
        import shlex
        import subprocess

        native_stdout = sys.stdout
        native_stderr = sys.stderr
        output_buffer = io.StringIO()

        try:
            sys.stdout = output_buffer
            sys.stderr = output_buffer

            meta = event["_serverless-wsgi"]
            if meta.get("command") == "exec":
                # Evaluate Python code
                exec(meta.get("data", ""))
            elif meta.get("command") == "command":
                # Run shell commands
                result = subprocess.check_output(meta.get("data", ""),
                                                 shell=True,
                                                 stderr=subprocess.STDOUT)
                output_buffer.write(result.decode())
            elif meta.get("command") == "manage":
                # Run Django management commands
                from django.core import management

                management.call_command(*shlex.split(meta.get("data", "")))
            elif meta.get("command") == "flask":
                # Run Flask CLI commands
                from flask.cli import FlaskGroup

                flask_group = FlaskGroup(create_app=_create_app)
                flask_group.main(shlex.split(meta.get("data", "")),
                                 standalone_mode=False)
            else:
                raise Exception("Unknown command: {}".format(
                    meta.get("command")))
        except subprocess.CalledProcessError as e:
            return [e.returncode, e.output.decode("utf-8")]
        except:  # noqa
            return [1, traceback.format_exc()]
        finally:
            sys.stdout = native_stdout
            sys.stderr = native_stderr

        return [0, output_buffer.getvalue()]
    else:
        return serverless_wsgi.handle_request(wsgi_app, event, context)
Exemplo n.º 7
0
def handle(event, context):
    context.get_remaining_time_in_millis()

    # transfer stage from event["requestContext"] to an X-Stage header
    event["headers"]["X-Stage"] = event.get("requestContext", {}).pop("stage", None)
    event["headers"]["Host"] = event["headers"].get(
        "X-Forwarded-Host", event["headers"].get("Host")
    )

    app.wsgi_app = TimeoutMiddleware(
        app.wsgi_app, context.get_remaining_time_in_millis() - 50
    )

    return serverless_wsgi.handle_request(app, event, context)
Exemplo n.º 8
0
def handler(event, context):
    if "Records" in event:
        process_sqs_messages(event)
        return
    """Lambda event handler, invokes the WSGI wrapper and handles command invocation"""
    if "_serverless-wsgi" in event:
        import shlex
        import subprocess

        from werkzeug._compat import StringIO, to_native

        native_stdout = sys.stdout
        native_stderr = sys.stderr
        output_buffer = StringIO()

        try:
            sys.stdout = output_buffer
            sys.stderr = output_buffer

            meta = event["_serverless-wsgi"]
            if meta.get("command") == "exec":
                # Evaluate Python code
                exec(meta.get("data", ""))
            elif meta.get("command2") == "command":
                # Run shell commands
                result = subprocess.check_output(meta.get("data", ""),
                                                 shell=True,
                                                 stderr=subprocess.STDOUT)
                output_buffer.write(to_native(result))
            elif meta.get("command") == "manage":
                # Run Django management commands
                from django.core import management

                management.call_command(*shlex.split(meta.get("data", "")))
            else:
                raise Exception("Unknown command: {}".format(
                    meta.get("command")))
        except subprocess.CalledProcessError as e:
            return [e.returncode, e.output.decode("utf-8")]
        except:  # noqa
            return [1, traceback.format_exc()]
        finally:
            sys.stdout = native_stdout
            sys.stderr = native_stderr

        return [0, output_buffer.getvalue()]
    else:
        return serverless_wsgi.handle_request(wsgi_app, event, context)
def lambda_handler(event, context):
    """Lambda handler entry point

    :param event: An event from an ALB
    :param context: An AWS context object
    :returns: An AWS ALB event
    :rtype: dict


    """

    sk = os.getenv("SECRET_KEY", "FALSE")
    if sk is not "FALSE":
        app.app.server_key = sk
        app.app.config["SECRET_KEY"] = sk

    return serverless_wsgi.handle_request(app.app, event, context)
Exemplo n.º 10
0
def lambda_handler(event, context):
    return serverless_wsgi.handle_request(app, event, context)
Exemplo n.º 11
0
def handle_request(event, context):
    return serverless_wsgi.handle_request(app, event, context)
Exemplo n.º 12
0
def handler(event, context):
    return serverless_wsgi.handle_request(connexion_app.app, event, context)
Exemplo n.º 13
0
def handle(event, context):
    logger = setup_logging()
    logger.debug("Profile retrieval service Initialized.")
    app = cis_profile_retrieval_service.v2_api.app
    return serverless_wsgi.handle_request(app, event, context)
Exemplo n.º 14
0
def handle(event, context):
    logger = setup_logging()
    logger.info("Profile retrieval initialized.")
    return serverless_wsgi.handle_request(cis_profile_retrieval_service.v2_api.app, event, context)
Exemplo n.º 15
0
def handle(event, context):
    logger = setup_logging()
    logger.info("Change Service Initialized.")
    return serverless_wsgi.handle_request(cis_change_service.api.app, event, context)
Exemplo n.º 16
0
def lambda_handler(event, context):
    response = serverless_wsgi.handle_request(app, event, context)
    app.logger.info('WSGI got me this: %s', response)
    return response
Exemplo n.º 17
0
def lambda_handler(event, context):
    return handle_request(app, event, context)
Exemplo n.º 18
0
def main(event, context):
    """Handle request."""
    return serverless_wsgi.handle_request(app.app, event, context)
Exemplo n.º 19
0
def handler(event, context):
    return serverless_wsgi.handle_request(slackapp.app, event, context)
Exemplo n.º 20
0
def api(event, context):
    event["headers"]["X-Forwarded-Host"] = os.environ["BASE_URL"]
    print("REQUEST: ", event)
    return handle_request(application, event, context)
Exemplo n.º 21
0
def api(event, context):
    event["headers"]["Host"] = os.environ["BASE_URL"]
    print("REQUEST: ", event)
    return handle_request(create_app(), event, context)
def lambda_handler(event, context):
    print(event)
    print(context)
    return serverless_wsgi.handle_request(app.server, event, context)
def handler(event, context):
    return serverless_wsgi.handle_request({{django_project}}.wsgi.application, event, context)
Exemplo n.º 24
0
def main_handler(event, context):
    return serverless_wsgi.handle_request(app.wsgi_app, event, context)
def run(event, context):
    config.load_environment(app)
    config.load_settings(app)
    return serverless_wsgi.handle_request(app, event, context)
Exemplo n.º 26
0
def handle(event, context):
    logger = setup_logging()
    logger.debug("serverless handler for hris started")
    return serverless_wsgi.handle_request(api.app, event, context)
Exemplo n.º 27
0
def make_handler(wsgi_app):
    """ Factory that builds a Lambda event handler for a given WSGI application
    """
    return lambda event, context: serverless_wsgi.handle_request(
        wsgi_app, event, context)
Exemplo n.º 28
0
def handle(event, context):

    if 'django_command' in event:
        return execute(event['django_command'])

    return serverless_wsgi.handle_request(application, event, context)
Exemplo n.º 29
0
def run(event, context):
    config.load_environment(app)
    config.setup_talisman(app)
    config.load_ssm_parameters(app)
    return serverless_wsgi.handle_request(app, event, context)