Skip to content

Commit

Permalink
Added optional flag to write results to console or file
Browse files Browse the repository at this point in the history
  • Loading branch information
doughon committed Sep 18, 2024
1 parent ab9aeb1 commit d97d8e9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions operations/auditing/createAuditReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
'--lookerUrlPrefix',
help='Looker url prefix such as https://looker.local:19999'
'/api/3.1 overriding env var lookerUrlPrefix')
parser.add_argument('-f',
'--file',
help='Write results to a csv file at the specified path')

args = parser.parse_args()

Expand All @@ -46,6 +49,7 @@
pgPassword = args.pgPassword or os.getenv('PGPASSWORD')
lookerUrlPrefix = args.lookerUrlPrefix or os.getenv('lookerUrlPrefix')
lookerClientSecret = args.lookerClientSecret
file = args.file

# prompt user to supply missing mandatory information
if pgHost is None:
Expand Down Expand Up @@ -162,5 +166,8 @@
# reorder columns
dfMerged = dfMerged.iloc[:,[0,1,3,4,2]]

# print results to console
print(dfMerged.to_csv(index=False, quoting=2))
# print results to console# if output is not set print results to console
if file is None:
print(dfMerged.to_csv(index=False, quoting=2))
else:
dfMerged.to_csv(path_or_buf=file, index=False, quoting=2)

0 comments on commit d97d8e9

Please sign in to comment.