def getFilesByMetadataQuery(self, query): """Return a list of LFNs satisfying given query conditions. Example usage: >>> badger.getFilesByMetadataQuery('resonance=jpsi bossVer=6.5.5 expNum=exp1') ['/bes/File/jpsi/6.5.5/data/all/exp1/file1', .....] """ #TODO: checking of output, error catching fc = self.client #TODO: calling the FileCatalog CLI object and its private method # is not a good way of doing this! but use it to allow construction of # the query meantime, until createQuery is made a public method cli = FileCatalogClientCLI(fc) metadataDict = cli._FileCatalogClientCLI__createQuery(query) result = fc.findFilesByMetadata(metadataDict,'/') if result['OK']: lfns = fc.findFilesByMetadata(metadataDict,'/')['Value'] lfns.sort() return lfns else: print "ERROR: No files found which match query conditions." return None
def registerDataset(self, datasetName, path, conditions): """Register a new dataset in DFC. Takes dataset name and string with conditions for new dataset as arguments. datasetname format: resonance_BossVer_eventtype_round_runL_runH_stream0_datatype resonance_BossVer_eventtype_round_runL_runH_streamID_datatype type(conditions) is str,like "resonance=jpsi bossVer=655 round=round1" """ fc = self.client cli = FileCatalogClientCLI(fc) metadataDict = cli._FileCatalogClientCLI__createQuery(conditions) metadataDict["Path"] = path result = fc.addDataset(datasetName, metadataDict) if not result["OK"]: print ("Error: %s" % result["Message"]) return S_ERROR() else: print "Added dataset %s with conditions %s" % (datasetName, conditions) return S_OK()
def registerDataset(self, datasetName, path, conditions): """Register a new dataset in DFC. Takes dataset name and string with conditions for new dataset as arguments. datasetname format: resonance_BossVer_eventtype_round_runL_runH_stream0_datatype resonance_BossVer_eventtype_round_runL_runH_streamID_datatype type(conditions) is str,like "resonance=jpsi bossVer=655 round=round1" """ fc = self.client cli = FileCatalogClientCLI(fc) metadataDict = cli._FileCatalogClientCLI__createQuery(conditions) metadataDict['Path'] = path result = fc.addDataset(datasetName, metadataDict) if not result['OK']: print("Error: %s" % result['Message']) return S_ERROR() else: print "Added dataset %s with conditions %s" % (datasetName, conditions) return S_OK()