Skip to content

Commit

Permalink
Merge pull request #7779 from ic-hep/checkdirexists
Browse files Browse the repository at this point in the history
[v8r0] fix: dirac_dms_find_lfns: check if requested path exists and return error if not
  • Loading branch information
fstagni authored Sep 11, 2024
2 parents cc2c6e5 + ea5c42c commit f54f7cf
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 f54f7cf

Please sign in to comment.