简体   繁体   English

python boto3分页:aws工作区

[英]python boto3 pagination: aws workspaces

I am new to Python.我是 Python 新手。 I have a script (in aws lambda function) that loops over my AWS workspace items and prints out some info, however, it only prints out about 25 of the items instead of 200+ items.我有一个脚本(在 aws lambda 函数中)循环遍历我的 AWS 工作区项目并打印出一些信息,但是,它只打印出大约 25 个项目而不是 200 多个项目。 So i turned to paginators.所以我转向分页器。 But it is not working as the script is not printing out the info.但它不起作用,因为脚本没有打印出信息。 Rather it is printing "uh oh".而是打印“呃哦”。 Here is the script:这是脚本:

final_detail = [] final_detail.append(['ComputerName', 'WorkspaceId', 'IpAddress', 'state', 'UserName', 'BundleId', 'WorkspaceProperties']) final_detail = [] final_detail.append(['ComputerName', 'WorkspaceId', 'IpAddress', 'state', 'UserName', 'BundleId', 'WorkspaceProperties'])

try:
    paginator = client.get_paginator('describe_workspaces')
    for workspaceInfo in paginator.paginate():
        for each_detail in workspaceInfo["ComputerName"],["WorkspaceId"],["IpAddress"],["state"],["UserName"],["BundleId"], ["WorkspaceProperties"]:
            final_detail.append(each_detail)
            # pprint(final_detail)
except:
     details = None
     print('uh oh')

workspaceInfo is an iterator in your code, so you're accessing wrong object. workspaceInfo是您代码中的迭代器,因此您访问的是错误的对象。 This should work.这应该有效。

paginator = client.get_paginator('describe_workspaces')
for workspaces in paginator.paginate():
    for workspaceInfo in workspaces: 
        each_detail = workspaceInfo["ComputerName"],["WorkspaceId"],["IpAddress"],["state"],["UserName"],["BundleId"], ["WorkspaceProperties"]
        final_detail.append(each_detail)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM