Skip to content

Commit 77a0fd3

Browse files
add fails for missing directories
1 parent 7aa5df1 commit 77a0fd3

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

dms_datastore/populate_repo.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -597,11 +597,9 @@ def ncro_only(dest):
597597

598598
def populate_main(dest, agencies=None, varlist=None, partial_update=False):
599599

600-
601600
do_purge = False
602601
if not os.path.exists(dest):
603-
os.mkdir(dest)
604-
logger.info(f"Directory {dest} created")
602+
raise ValueError(f"Destination directory {os.path.abspath(dest)} does not exist. Please create it before running populate.")
605603
else:
606604
if do_purge:
607605
purge(dest)
@@ -649,8 +647,7 @@ def populate_main(dest, agencies=None, varlist=None, partial_update=False):
649647
def populate_debug_ncro_rename(dest, agencies=None, varlist=None):
650648
do_purge = False
651649
if not os.path.exists(dest):
652-
os.mkdir(dest)
653-
logger.info(f"Directory {dest} created")
650+
raise ValueError(f"Destination directory {os.path.abspath(dest)} does not exist. Please create it before running populate.")
654651
else:
655652
if do_purge:
656653
purge(dest)

dms_datastore/reformat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ def reformat(inpath, outpath, pattern):
509509
def reformat_main(
510510
inpath="raw", outpath="formatted", agencies=["usgs", "des", "cdec", "noaa", "ncro"]
511511
):
512+
if not os.path.exists(outpath):
513+
raise ValueError(f"Destination directory {os.path.abspath(outpath)} does not exist. Please create it before running reformat.")
512514
if not isinstance(agencies, list):
513515
agencies = [agencies]
514516
all_agencies = agencies

0 commit comments

Comments
 (0)