Ejemplo n.º 1
0
 def test_get_stdin(self):
     sys.stdin = io.StringIO('It works!')
     self.assertEqual(SysUtils.get_stdin(), 'It works!')
Ejemplo n.º 2
0
@exception()
def _create_supervisor(event, context=None):
    """Returns a new supervisor based on the
    environment.
    Binary mode by default"""
    supervisor = None
    if SysUtils.is_lambda_environment():
        supervisor = LambdaSupervisor(event, context)
    else:
        supervisor = BinarySupervisor()
    return supervisor


def main(event, context=None):
    """Initializes the generic supervisor
    and launches its execution."""
    configure_logger()
    get_logger().debug("EVENT received: %s", event)
    if context:
        get_logger().debug("CONTEXT received: %s", context)
    supervisor = Supervisor(event, context)
    return supervisor.run()


if __name__ == "__main__":
    # If supervisor is running as a binary
    # receive the input from stdin.
    ret = main(SysUtils.get_stdin())
    if ret is not None:
        print(ret)