Skip to content

Commit

Permalink
sweep: #742 fix (FC): match python handler and js for arg names
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen authored and web-flow committed Jul 28, 2023
1 parent 0b4388c commit dfeb09e
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/WebAppDIRAC/WebApp/handler/FileCatalogHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ def initializeRequest(self):
self.vo = getVOForGroup(self.group)
self.fc = FileCatalog(vo=self.vo)

def web_getSelectedFiles(self, archivePath=None, lfnPath=None):
def web_getSelectedFiles(self, archivePath=None, path=None):
"""Method to get the selected file(s)
:param str archivePath: archive path
:param str lfnPath: path LFN
:param str path: path LFN
:return: dict
"""
if lfnPath is None:
lfnPath = ""
if path is None:
path = ""

# First pass: download files and check for the success
if not archivePath:
Expand All @@ -44,7 +44,7 @@ def web_getSelectedFiles(self, archivePath=None, lfnPath=None):
if not os.path.isdir(tmpdir):
os.makedirs(tmpdir)
os.chdir(tmpdir)
for lfn in lfnPath.split(","):
for lfn in path.split(","):
gLogger.always(f"Data manager get file {lfn}")
last_slash = lfn.rfind("/")
pos_relative = lfn.find("/")
Expand Down Expand Up @@ -112,15 +112,15 @@ def web_getMetadataFields(self):
gLogger.debug(f"getSelectorGrid: Resulting callback {callback}")
return {"success": "true", "result": callback}

def web_getQueryData(self, lfnPath=None, **kwargs):
def web_getQueryData(self, path=None, **kwargs):
"""Method to read all the available options for a metadata field
:param str lfnPath: path LFN
:param str path: path LFN
:return: dict
"""
if lfnPath is None:
lfnPath = "/"
if path is None:
path = "/"

try:
compat = {}
Expand Down Expand Up @@ -156,19 +156,19 @@ def web_getQueryData(self, lfnPath=None, **kwargs):

gLogger.always(compat)

result = self.fc.getCompatibleMetadata(compat, lfnPath)
result = self.fc.getCompatibleMetadata(compat, path)
gLogger.always(result)

if not result["OK"]:
return {"success": "false", "error": result["Message"]}
return {"success": "true", "result": result["Value"]}

def web_getFilesData(self, limit=25, start=0, lfnPath=None, **kwargs):
def web_getFilesData(self, limit=25, start=0, path=None, **kwargs):
"""Get files data
:param int limit: limit
:param int start: start
:param str lfnPath: path
:param str path: path
:return: dict
"""
Expand Down Expand Up @@ -208,8 +208,8 @@ def web_getFilesData(self, limit=25, start=0, lfnPath=None, **kwargs):
req["selection"][name][logic] = value[1]
elif value[0] == "s":
req["selection"][name][logic] += value[1].split(":::")
if lfnPath:
req["path"] = lfnPath
if path:
req["path"] = path

gLogger.debug(f"submit: incoming request {req}")
result = self.fc.findFilesByMetadataWeb(req["selection"], req["path"], start, limit)
Expand Down Expand Up @@ -257,11 +257,11 @@ def web_getFilesData(self, limit=25, start=0, lfnPath=None, **kwargs):
timestamp = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M [UTC]")
return {"success": "true", "result": callback, "total": total, "date": timestamp}

def web_getMetadataFilesInFile(self, selection="", lfnPath=None):
def web_getMetadataFilesInFile(self, selection="", path=None):
"""Get metadata files
:param str selection: selection
:param str lfnPath: path
:param str path: path
:return: dict
"""
Expand Down Expand Up @@ -307,8 +307,8 @@ def web_getMetadataFilesInFile(self, selection="", lfnPath=None):
req["selection"][name][logic] = tmp[3]
elif tmp[2] == "s":
req["selection"][name][logic] += tmp[3].split(":::")
if lfnPath:
req["path"] = lfnPath
if path:
req["path"] = path

gLogger.debug("submit: incoming request", req)
result = self.fc.findFilesByMetadata(req["selection"], req["path"])
Expand All @@ -318,20 +318,20 @@ def web_getMetadataFilesInFile(self, selection="", lfnPath=None):

return FileResponse("\n".join([fileName for fileName in result["Value"]]), str(req))

def web_getSubnodeFiles(self, lfnPath):
def web_getSubnodeFiles(self, path):
"""Get subnode files
:param str lfnPath: path
:param str path: path
:return: dict
"""
result = self.fc.listDirectory(lfnPath, False)
result = self.fc.listDirectory(path, False)
if not result["OK"]:
gLogger.error("submit:", result["Message"])
return {"success": "false", "error": result["Message"]}

filesData = result["Value"]["Successful"][lfnPath]["Files"]
dirData = result["Value"]["Successful"][lfnPath]["SubDirs"]
filesData = result["Value"]["Successful"][path]["Files"]
dirData = result["Value"]["Successful"][path]["SubDirs"]

retData = []

Expand Down

0 comments on commit dfeb09e

Please sign in to comment.