diff options
author | Frederick Muriuki Muriithi | 2023-05-25 19:19:22 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-05-25 19:19:22 +0300 |
commit | 88d4f61e4df7dcffaaed083989c75ee9ad4a48a4 (patch) | |
tree | a30db9379949475b054061110ae47422147b676e | |
parent | 256f13f675c60547b10a06736f0a7cb3faf752d5 (diff) | |
download | genenetwork3-88d4f61e4df7dcffaaed083989c75ee9ad4a48a4.tar.gz |
Add some error checks.
-rw-r--r-- | scripts/migrate_existing_data.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/scripts/migrate_existing_data.py b/scripts/migrate_existing_data.py index ecad39c..5c7e568 100644 --- a/scripts/migrate_existing_data.py +++ b/scripts/migrate_existing_data.py @@ -4,6 +4,7 @@ group for accessibility purposes. """ import sys import json +from pathlib import Path from uuid import UUID, uuid4 import click @@ -336,12 +337,17 @@ def assign_data_to_resource(authconn, bioconn, resource: Resource): authconn, bioconn, resource) @click.command() -@click.argument("authdburi") # "URI to the Auth(entic|oris)ation database" +@click.argument("authdbpath") # "Path to the Auth(entic|oris)ation database" @click.argument("mysqldburi") # "URI to the MySQL database with the biology data" -def run(authdburi, mysqldburi): +def run(authdbpath, mysqldburi): """Entry-point for data migration.""" + if not Path(authdbpath).exists(): + print( + f"ERROR: Auth db file `{authdbpath}` does not exist.", + file=sys.stderr) + sys.exit(2) try: - with (authdb.connection(authdburi) as authconn, + with (authdb.connection(authdbpath) as authconn, biodb.database_connection(mysqldburi) as bioconn): admin = select_sys_admin(sys_admins(authconn)) resources = default_resources( |