本文整理汇总了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
示例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)