Skip to content

Commit

Permalink
Write results to file
Browse files Browse the repository at this point in the history
  • Loading branch information
Charl1996 committed Sep 11, 2024
1 parent f7658db commit 1f6097c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions hq_superset/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def data_sources_by_domain():
webhook_url = f"{superset_base_url}/change/"
token_url = f"{superset_base_url}/token"

failed_data_source_ids = {}
failed_data_sources_by_id = {}
for domain, datasource_ids in data_sources_by_domain().items():
for datasource_id in datasource_ids:
client = _get_or_create_oauth2client(domain)
Expand All @@ -43,9 +43,11 @@ def data_sources_by_domain():
)

if response.status_code != 201:
failed_data_source_ids[datasource_id] = response.content
failed_data_sources_by_id[datasource_id] = response

print("Done!")
if failed_data_source_ids:
print("The following data sources failed to subscribe")
print(failed_data_source_ids)
if failed_data_sources_by_id:
print("Some data sources failed to subscribe. See subscribe-datasources.errors for more details")
with open("subscribe-datasources.errors", 'w') as file:
for ds_id, response in failed_data_sources_by_id.items():
file.write(f"ID: {ds_id} :: Status Code: {response.status_code} :: Reason: {response.content}\n")

0 comments on commit 1f6097c

Please sign in to comment.