Пример #1
0
 def listDirectory(self, path):
     """List the contents of the directory"""
     res = checkArgumentFormat(path)
     if not res["OK"]:
         return res
     urls = res["Value"]
     successful = {}
     failed = {}
     gLogger.debug("DIPStorage.listDirectory: Attempting to list %s directories." % len(urls))
     serviceClient = Client(url=self.url)
     for url in urls:
         res = serviceClient.listDirectory(url, "l")
         if not res["OK"]:
             failed[url] = res["Message"]
         else:
             files = {}
             subDirs = {}
             for subPath, pathDict in res["Value"].items():
                 if pathDict["Type"] == "File":
                     files[subPath] = pathDict
                 elif pathDict["Type"] == "Directory":
                     subDirs[subPath] = pathDict
             successful[url] = {}
             successful[url]["SubDirs"] = subDirs
             successful[url]["Files"] = files
     resDict = {"Failed": failed, "Successful": successful}
     return S_OK(resDict)