当前位置: 首页>>代码示例>>Python>>正文


Python Zappa.fetch_logs方法代码示例

本文整理汇总了Python中zappa.zappa.Zappa.fetch_logs方法的典型用法代码示例。如果您正苦于以下问题:Python Zappa.fetch_logs方法的具体用法?Python Zappa.fetch_logs怎么用?Python Zappa.fetch_logs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zappa.zappa.Zappa的用法示例。


在下文中一共展示了Zappa.fetch_logs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: from zappa.zappa import Zappa [as 别名]
# 或者: from zappa.zappa.Zappa import fetch_logs [as 别名]
    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
开发者ID:codingjoe,项目名称:django-zappa,代码行数:55,代码来源:tail.py

示例2: test_fetch_logs

# 需要导入模块: from zappa.zappa import Zappa [as 别名]
# 或者: from zappa.zappa.Zappa import fetch_logs [as 别名]
 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)
开发者ID:ConfidentCannabis,项目名称:Zappa,代码行数:7,代码来源:tests.py


注:本文中的zappa.zappa.Zappa.fetch_logs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。