fix: Check result list before appending. Remove the need to clean final_data
This commit is contained in:
+3
-3
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user