apiTar = DbsApi(argsTar) path = sys.argv[3] print path #name = argsSrc['url'].replace('/','_') + "_" + argsTar['url'].replace('/', '_') + path.replace('/', '_') name = argsSrc['url'].replace('/','_').replace(':', '_') + "_" + argsTar['url'].replace('/', '_').replace(':', '_') blocks = apiSrc.listBlocks(path) if ((op == "both") | (op == "get")) : #Fetch the dataset contents and save them in a file for i in blocks: blockName = i['Name'] fileName = blockName.replace('/', '_').replace('#', '_') + ".xml" print "Fetching information for Block %s " % blockName xmlinput = apiSrc.listDatasetContents(path, blockName) f = open(name + fileName, "w"); f.write(xmlinput) f.close() print "Dataset information fetched from " + argsSrc['url'] + " in XML format is saved in " + name + fileName if ((op == "both") | (op == "set")) : #Insert the saved contents into another DBS instance for i in blocks: blockName = i['Name'] fileName = blockName.replace('/', '_').replace('#', '_') + ".xml" print "Inserting information for Block %s " % blockName f = open(name + fileName, "r"); xmlinput = f.read() f.close()
#!/usr/bin/env python # Revision: 1.3 $" # Id: DBSXMLParser.java,v 1.3 2006/10/26 18:26:04 afaq Exp $" # # API Unit tests for the DBS JavaServer. import sys from DBSAPI.dbsApi import DbsApi from DBSAPI.dbsException import * from DBSAPI.dbsApiException import * from DBSAPI.dbsOptions import DbsOptionParser try: optManager = DbsOptionParser() (opts,args) = optManager.getOpt() api = DbsApi(opts.__dict__) xml = api.listDatasetContents("/test_primary_001/TestProcessedDS001/SIM", "/test_primary_001/TestProcessedDS001/SIM#12345"); print xml print api.insertDatasetContents(xml) except DbsApiException, ex: print "Caught API Exception %s: %s " % (ex.getClassName(), ex.getErrorMessage() ) if ex.getErrorCode() not in (None, ""): print "DBS Exception Error Code: ", ex.getErrorCode()
api = DbsApi(opts.__dict__) datasets=[ #"/Cosmics/Commissioning08-v1/RAW", #"/TTbar/Summer09-MC_31X_V3-v1/GEN-SIM-RAW", "/TTbar/Summer09-MC_31X_V3-v1/GEN-SIM-RECO", "/BeamHalo/Summer09-STARTUP31X_V7_StreamMuAlBeamHaloOverlaps-v1/ALCARECO", "/InclusiveMu15/Summer09-MC_31X_V3_7TeV-v1/GEN-SIM-RAW", "/Cosmics/CMSSW_3_2_7-CRAFT09_R_V4_CosmicsSeq-v1/RECO", "/Wmunu/Summer09-MC_31X_V3_7TeV_SD_L1_L2_Mu-v1/GEN-SIM-RECO", "/Wmunu/Summer09-MC_31X_V3_7TeV_SD_Mu9-v1/GEN-SIM-RECO" ] #datasets=["/TTbar/Summer09-MC_31X_V3-v1/GEN-SIM-RAW"] for dataset in datasets : blocks=api.listBlocks(dataset) for ablock in blocks: data=api.listDatasetContents(dataset, ablock["Name"]) #print data print "-- SQL Statements for Dataset : %s and Block : %s " % (dataset, ablock["Name"]) class Handler (xml.sax.handler.ContentHandler): def __init__(self): self.sqls={} self.sqls['paths']=[] self.sqls['storage_element']=[] self.sqls['block_storage_elements']=[] self.sqls['file']=[] self.sqls['app_version']=[] self.sqls['app_executable_name']=[] self.sqls['ps_hash']=[] self.sqls['process_configurations']=[] self.sqls['processed_dataset_algorithm']=[]
print path #name = argsSrc['url'].replace('/','_') + "_" + argsTar['url'].replace('/', '_') + path.replace('/', '_') #name = argsSrc['url'].replace('/','_').replace(':', '_') + "_" + argsTar['url'].replace('/', '_').replace(':', '_') name = "Transfer_" blocks = apiSrc.listBlocks(path) if ((op == "both") | (op == "get")) : #Fetch the dataset contents and save them in a file for i in blocks: blockName = i['Name'] fileName = blockName.replace('/', '_').replace('#', '_') + ".xml" if os.path.exists(name + fileName): print "WARNNING The XML file " + name + fileName + " exists already and will be used. The information will not be fetched again" else: print "Fetching information for Block %s " % blockName xmlinput = apiSrc.listDatasetContents(path, blockName) f = open(name + fileName, "w"); f.write(xmlinput) f.close() print "Dataset information fetched from " + argsSrc['url'] + " in XML format is saved in " + name + fileName if ((op == "both") | (op == "set")) : #Insert the saved contents into another DBS instance print len(blocks) for i in blocks: if i['Name'] == '/Wmunu/CMSSW_1_6_7-CSA07-Tier1-ALCA-C1-ALCARECOMuAlZMuMu/ALCARECO#ac03b7e3-5eac-4b80-9ed9-32c4a7f773c3': continue print "blocks number of Files %s ", i['NumberOfFiles'] if(i['NumberOfFiles'] > 0): blockName = i['Name'] fileName = blockName.replace('/', '_').replace('#', '_') + ".xml"
datasetpath = myarg if datasetpath == None: print "Please specify --dataset" sys.exit(2) se = 'srm.cern.ch' try: outputname = datasetpath.replace('/', '_')[1:] + '.xml' outputfile = file(outputname.replace('PreCSA08', 'CSA08'), 'w') output = "" api = DbsApi(dbsargs) try: blocks = api.listBlocks(dataset=datasetpath, block_name="*", storage_element_name=se) except: blocks = [] for block in blocks: output += api.listDatasetContents(datasetpath, block['Name']) newoutput = output.replace('PreCSA08', 'CSA08') outputfile.write(newoutput) outputfile.close() except DbsApiException, ex: print "Caught API Exception %s: %s " % (ex.getClassName(), ex.getErrorMessage()) if ex.getErrorCode() not in (None, ""): print "DBS Exception Error Code: ", ex.getErrorCode()
#!/usr/bin/env python # # API Unit tests for the DBS JavaServer. import sys from DBSAPI.dbsApi import DbsApi from DBSAPI.dbsException import * from DBSAPI.dbsApiException import * from DBSAPI.dbsOptions import DbsOptionParser try: optManager = DbsOptionParser() (opts,args) = optManager.getOpt() api = DbsApi(opts.__dict__) xml = api.listDatasetContents("/test_primary_anzar_001/SIM/TestProcessedDS002", "/this/hahah#12345"); print xml print api.insertDatasetContents(xml) except DbsApiException, ex: print "Caught API Exception %s: %s " % (ex.getClassName(), ex.getErrorMessage() ) if ex.getErrorCode() not in (None, ""): print "DBS Exception Error Code: ", ex.getErrorCode()
datasetpath = myarg if datasetpath == None: print "Please specify --dataset" sys.exit(2) se = 'srm.cern.ch' try: outputname = datasetpath.replace('/','_')[1:]+'.xml' outputfile = file(outputname.replace('PreCSA08','CSA08'),'w') output = "" api = DbsApi(dbsargs) try: blocks = api.listBlocks(dataset=datasetpath,block_name="*",storage_element_name=se); except: blocks = [] for block in blocks: output += api.listDatasetContents(datasetpath,block['Name']) newoutput = output.replace('PreCSA08','CSA08') outputfile.write(newoutput) outputfile.close() except DbsApiException, ex: print "Caught API Exception %s: %s " % (ex.getClassName(), ex.getErrorMessage() ) if ex.getErrorCode() not in (None, ""): print "DBS Exception Error Code: ", ex.getErrorCode()