Пример #1
0
    def handle(self, *args, **options):
        """
        Execute the command.

        """
        if not options.has_key('environment'):
            print("You must call deploy with an environment name. \n python manage.py deploy <environment>")
            return

        from django.conf import settings
        if not 'ZAPPA_SETTINGS' in dir(settings):
            print("Please define your ZAPPA_SETTINGS in your settings file before deploying.")
            return

        zappa_settings = settings.ZAPPA_SETTINGS

        # Set your configuration
        project_name = settings.BASE_DIR.split(os.sep)[-1]
        api_stage = options['environment'][0]
        if api_stage not in zappa_settings.keys():
            print("Please make sure that the environment '" + api_stage + "' is defined in your ZAPPA_SETTINGS in your settings file before deploying.")
            return
        lambda_name = project_name + '-' + api_stage

        # Make your Zappa object
        zappa = Zappa()

        # Load your AWS credentials from ~/.aws/credentials
        zappa.load_credentials()

        try:
            # Tail the available logs
            all_logs = zappa.fetch_logs(lambda_name)
            self.print_logs(all_logs)

        # Keep polling, and print any new logs.
            while True:
                all_logs_again = zappa.fetch_logs(lambda_name)
                new_logs = []
                for log in all_logs_again:
                    if log not in all_logs:
                        new_logs.append(log)

                self.print_logs(new_logs)
                all_logs = all_logs + new_logs
        except KeyboardInterrupt:
            # Die gracefully
            try:
                sys.exit(0)
            except SystemExit:
                os._exit(0)

        return
Пример #2
0
 def test_fetch_logs(self, session):
     z = Zappa(session)
     z.credentials_arn = 'arn:aws:iam::12345:role/ZappaLambdaExecution'
     events = z.fetch_logs('Spheres-demonstration')
     self.assertTrue(events is not None)
Пример #3
0
 def test_fetch_logs(self, session):
     z = Zappa(session)
     z.credentials_arn = 'arn:aws:iam::12345:role/ZappaLambdaExecution'
     events = z.fetch_logs('Spheres-demonstration')
     self.assertTrue(events is not None)