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 10, 2024
1 parent 4bfb083 commit 5a15a3f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 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,18 @@ def main():
DIRAC.exit(-1)
metaDict = result["Value"]
path = metaDict.pop("Path", path)

# check if path exists and is a directory
{'OK': True, 'Value': {'Failed': {}, 'Successful': {'/gridpp/user/d/daniela.bauer/0/666': False}}}
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 5a15a3f

Please sign in to comment.