本文整理汇总了Python中DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient.removeDirectory方法的典型用法代码示例。如果您正苦于以下问题:Python FileCatalogClient.removeDirectory方法的具体用法?Python FileCatalogClient.removeDirectory怎么用?Python FileCatalogClient.removeDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient
的用法示例。
在下文中一共展示了FileCatalogClient.removeDirectory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from DIRAC.Resources.Catalog.FileCatalogClient import FileCatalogClient [as 别名]
# 或者: from DIRAC.Resources.Catalog.FileCatalogClient.FileCatalogClient import removeDirectory [as 别名]
#.........这里部分代码省略.........
if create_round:
if metaDict["streamId"] != "stream0":
dir_exists = self.__dirExists(dir_streamId, dir_round)
if not dir_exists:
if self.__registerDir(dir_streamId)["OK"]:
result = self.__registerDirMetadata(dir_streamId, {"streamId": metaDict["streamId"]})
if result["OK"]:
result = self.__registerDirMetadata(dir_streamId, lastDirMetaDict)
if result["OK"]:
creation_OK = 1
else:
creation_OK = 2
else:
result = self.__registerDirMetadata(dir_round, lastDirMetaDict)
if result["OK"]:
creation_OK = 1
if (creation_OK == 1) | (creation_OK == 2):
if metaDict["streamId"] == "stream0":
return dir_round
else:
return dir_streamId
##########################################################################################
# dir options
def removeDir(self, dir):
"""remove the dir include files and subdirs
"""
result = self.client.listDirectory(dir)
if result["OK"]:
if not result["Value"]["Successful"][dir]["Files"] and not result["Value"]["Successful"][dir]["SubDirs"]:
# print 'no file and subDirs in this dir'
self.client.removeDirectory(dir)
return S_OK()
else:
if result["Value"]["Successful"][dir]["Files"]:
for file in result["Value"]["Successful"][dir]["Files"]:
self.client.removeFile(file)
else:
for subdir in result["Value"]["Successful"][dir]["SubDirs"]:
self.removeDir(subdir)
self.removeDir(dir)
def listDir(self, dir):
"""list the files under the given DFC dir"""
fileList = []
result = self.client.listDirectory(dir)
if result["OK"]:
if result["Value"]["Successful"][dir]["Files"]:
fileList = result["Value"]["Successful"][dir]["Files"].keys()
fileList.sort()
else:
print "no files under this dir"
return fileList
def getDirMetaVal(self, dir):
"""list the registed metadata value of the given dir"""
result = self.client.getDirectoryMetadata(dir)
if result["OK"]:
return result["Value"]
else:
print "Failed to get meta Value of the directory"
return {}
#################################################################################