Skip to content

Commit

Permalink
admin/log-the-target-db-env (#41)
Browse files Browse the repository at this point in the history
* Log the target db env

* Remove .strip call
  • Loading branch information
tohuynh committed Sep 17, 2021
1 parent 1e0c1bf commit c277084
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion siglatools/bin/load_spreadsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def main():
]
if not spreadsheet_ids:
raise Exception("No spreadsheet ids found.")
if args.db_env.strip() not in [Environment.staging, Environment.production]:
if args.db_env not in [Environment.staging, Environment.production]:
raise Exception(
"Incorrect database enviroment specification. Use 'staging' or 'production'."
)
Expand All @@ -335,6 +335,9 @@ def main():
if args.db_env == Environment.staging
else args.prod_db_connection_url
)
log.info(
f"""Loading spreadsheets {", ".join(spreadsheet_ids)} to the {args.db_env} database."""
)
load_spreadsheets(
spreadsheet_ids,
db_connection_url,
Expand Down
4 changes: 2 additions & 2 deletions siglatools/bin/run_qa_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,9 +1054,9 @@ def main():
try:
args = Args()
dbg = args.debug
if args.db_env.strip() not in [Environment.staging, Environment.production]:
if args.db_env not in [Environment.staging, Environment.production]:
raise Exception(
"Incorrect database enviroment specification. Use 'staging' or 'production'."
"Incorrect database environment specification. Use 'staging' or 'production'."
)
run_qa_test(
args.master_spreadsheet_id,
Expand Down
8 changes: 6 additions & 2 deletions siglatools/bin/run_sigla_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,19 @@ def main():
dbg = args.debug
if args.master_spreadsheet_id is None:
raise Exception("No main spreadsheet id found.")
if args.db_env.strip() not in [Environment.staging, Environment.production]:
if args.db_env not in [Environment.staging, Environment.production]:
raise Exception(
"Incorrect database enviroment specification. Use 'staging' or 'production'."
)
log.info(
f"""Loading all spreadsheets in the master spreadsheet {args.master_spreadsheet_id}""",
f" to the {args.db_env} database.",
)
run_sigla_pipeline(
args.master_spreadsheet_id,
args.google_api_credentials_path,
args.staging_db_connection_url
if args.db_env.strip() == Environment.staging
if args.db_env == Environment.staging
else args.prod_db_connection_url,
)
except Exception as e:
Expand Down

0 comments on commit c277084

Please sign in to comment.