From e7496dc9cbc83abe4ecc2edd7007f4913d0a91a9 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Sat, 26 Mar 2022 13:42:19 -0700 Subject: [PATCH] Fix bug in print vaultcounts ... account emailaddress (#1493) --- src/gam/gapi/vault.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gam/gapi/vault.py b/src/gam/gapi/vault.py index 29f417e1..973af9a1 100644 --- a/src/gam/gapi/vault.py +++ b/src/gam/gapi/vault.py @@ -348,7 +348,7 @@ def print_count(): # so we keep track of which accounts we searched and can report # zero data for them. if search_method == 'ACCOUNT': - query_accounts = query.get('accountInfo', []) + query_accounts = query.get('accountInfo', {}).get('emails', []) elif search_method == 'ENTIRE_ORG': query_accounts = gam.getUsersToModify('all', 'users') elif search_method == 'ORG_UNIT': @@ -367,8 +367,9 @@ def print_count(): if account in query_accounts: query_accounts.remove(account) for account in a_count.get('accountCounts', []): email = account.get('account', {}).get('email', '') - csv_rows.append({'account': email, 'count': account.get('count')}) - if email in query_accounts: query_accounts.remove(email) + if email: + csv_rows.append({'account': email, 'count': account.get('count', 0)}) + if email in query_accounts: query_accounts.remove(email) for account in query_accounts: csv_rows.append({'account': account, 'count': 0}) titles = ['account', 'count', 'error']