fix: Check result list before appending. Remove the need to clean final_data

This commit is contained in:
KenF
2026-01-22 20:01:20 +08:00
parent 0614cee9b2
commit 675f0f6ef3
10 changed files with 30 additions and 30 deletions
+3 -3
View File
@@ -27,7 +27,8 @@ def printResources(region_name: str) -> list[list[str | int]]:
if tag['Key'] == "Name":
name_tag = tag['Value']
break
return_data.append([i['InstanceId'], name_tag, i.get('PlatformDetails'), i['InstanceType'], i['PrivateIpAddress'], i['Placement']['AvailabilityZone']])
if i:
return_data.append([i['InstanceId'], name_tag, i.get('PlatformDetails'), i['InstanceType'], i['PrivateIpAddress'], i['Placement']['AvailabilityZone']])
return return_data
# Main function
@@ -44,8 +45,7 @@ def main() -> None:
region_data = future.result()
final_data.extend(region_data)
clean_data = [row for row in final_data if row]
for row in clean_data:
for row in final_data:
ws.append(row)
wb.save('aws-inventory.xlsx')