diff --git a/csst_dfs_api_local/cpic/ingest.py b/csst_dfs_api_local/cpic/ingest.py index 065e08092952de80297920fac51ac01da430bf4b..822126726939aed8d716ee79d1e1322591223617 100644 --- a/csst_dfs_api_local/cpic/ingest.py +++ b/csst_dfs_api_local/cpic/ingest.py @@ -9,14 +9,18 @@ from csst_dfs_api_local.common.db import DBClient log = logging.getLogger('csst-dfs-api-local') def ingest(): - db = DBClient() + parser = argparse.ArgumentParser(prog=f"{sys.argv[0]}", description="ingest the local files") parser.add_argument('-i','--infile', dest="infile", help="a file or a directory") parser.add_argument('-m', '--copyfiles', dest="copyfiles", action='store_true', default=False, help="copy files after import") args = parser.parse_args(sys.argv[1:]) import_root_dir = args.infile + if import_root_dir is None or (not os.path.isfile(import_root_dir) and not os.path.isdir(import_root_dir)): + parser.print_help() + sys.exit(0) + db = DBClient() if os.path.isfile(import_root_dir): log.info(f"prepare import {import_root_dir}") ingesst_one(import_root_dir, db, args.copyfiles) diff --git a/csst_dfs_api_local/msc/ingest.py b/csst_dfs_api_local/msc/ingest.py index 42b19b98c8682a553bf3b39b49a31863db391b34..f81a2a20b16553b68c54cf64395b783bf2343ae3 100644 --- a/csst_dfs_api_local/msc/ingest.py +++ b/csst_dfs_api_local/msc/ingest.py @@ -68,7 +68,7 @@ def ingest_one(file_path, db, copyfiles): filename = get_header_value("FILENAME", header, os.path.basename(file_path)) existed = db.exists( - "select * from t_level0_data where filename=?", + "select * from msc_level0_data where filename=?", (filename,) ) if existed: