Skip to content

Commit

Permalink
fix: check if requested path exists and return error if not
Browse files Browse the repository at this point in the history
  • Loading branch information
marianne013 committed Sep 11, 2024
1 parent 4bfb083 commit ea5c42c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/DIRAC/DataManagementSystem/scripts/dirac_dms_find_lfns.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@Script()
def main():
Script.registerSwitch("", "Path=", " Path to search for")
Script.registerSwitch("", "Path=", " Directory path to search for")
Script.registerSwitch("", "SE=", " (comma-separated list of) SEs/SE-groups to be searched")
# Registering arguments will automatically add their description to the help menu
Script.registerArgument(
Expand Down Expand Up @@ -59,7 +59,17 @@ def main():
DIRAC.exit(-1)
metaDict = result["Value"]
path = metaDict.pop("Path", path)

# check if path exists and is a directory
result = fc.isDirectory(path)
if not result["OK"]:
gLogger.error("Can not access File Catalog:", result["Message"])
DIRAC.exit(-1)
if path not in result["Value"]["Successful"]:
gLogger.error("Failed to query path status in file catalogue.", result["Message"])
DIRAC.exit(-1)
if not result["Value"]["Successful"][path]:
gLogger.error(f"{path} does not exist or is not a directory.")
DIRAC.exit(-1)
result = fc.findFilesByMetadata(metaDict, path)
if not result["OK"]:
gLogger.error("Can not access File Catalog:", result["Message"])
Expand Down

0 comments on commit ea5c42c

Please sign in to comment.