#!/usr/bin/env python # # Revision: 1.3 $" # Id: DBSXMLParser.java,v 1.3 2006/10/26 18:26:04 afaq Exp $" # import sys from DBSAPI.dbsApi import DbsApi from DBSAPI.dbsException import * from DBSAPI.dbsApiException import * from DBSAPI.dbsOptions import DbsOptionParser optManager = DbsOptionParser() (opts,args) = optManager.getOpt() api = DbsApi(opts.__dict__) try: print api.deleteFileParent("NEW_TEST0005xxxxxxxxxx6", "NEW_TEST0002") 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() print "Done"
for afile in merged1FileList: aFileLFN = afile['LogicalFileName'] print "Checking File %s in Merged dataset1" %aFileLFN parentListM1 = afile['ParentList'] for aparent in parentListM1: aparentLFN = aparent['LogicalFileName'] print "Getting parent of %s ( is grandparent of original file)" %aparentLFN tmpParentList = api.listFiles(patternLFN=aparentLFN, retriveList=['retrive_parent']) for atmpParent in tmpParentList: grandParentList = atmpParent['ParentList'] for agrandParent in grandParentList: print '__________________________________________________________' print 'INSERTING the real parent %s in Merged dataset1' %agrandParent['LogicalFileName'] print '__________________________________________________________\n\n' api.insertFileParent(aFileLFN, agrandParent['LogicalFileName']) print '****************************************************************************' print 'DELETING the parent %s from Merged dataset1' %aparentLFN print '****************************************************************************\n\n' api.deleteFileParent(aFileLFN, aparentLFN) 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() print "Done"
parentListM1 = aFileInM1['ParentList'] #print "checking the grandparent in %s" %parentListM1 if isIn(agrandParent, parentListM1): fileM1LFN = aFileInM1['LogicalFileName'] print '__________________________________________________________' print 'INSERTING the real parent %s in Merged dataset2' %fileM1LFN print '__________________________________________________________\n\n' api.insertFileParent(aFileLFN, fileM1LFN) else: print "Grand parent and parent did not match" if not isIn(aparent, merged1FileList): print '****************************************************************************' print 'DELETING the parent %s from Merged dataset2' %aparentLFN print '****************************************************************************\n\n' api.deleteFileParent(aFileLFN, aparentLFN) # Delete all the parents of merged1 dataset for afile in merged1FileList: print "Cheking File %s in Merged dataset1" %afile['LogicalFileName'] parentList = afile['ParentList'] for aparent in parentList: print '****************************************************************************' print 'DELETING the parent %s from Merged dataset1' %aparent['LogicalFileName'] print '****************************************************************************\n\n' api.deleteFileParent(afile['LogicalFileName'], aparent['LogicalFileName']) except DbsApiException, ex: print "Caught API Exception %s: %s " % (ex.getClassName(), ex.getErrorMessage() )
for afile in merged1FileList: aFileLFN = afile['LogicalFileName'] print "Checking File %s in Merged dataset1" % aFileLFN parentListM1 = afile['ParentList'] for aparent in parentListM1: aparentLFN = aparent['LogicalFileName'] print "Getting parent of %s ( is grandparent of original file)" % aparentLFN tmpParentList = api.listFiles(patternLFN=aparentLFN, retriveList=['retrive_parent']) for atmpParent in tmpParentList: grandParentList = atmpParent['ParentList'] for agrandParent in grandParentList: print '__________________________________________________________' print 'INSERTING the real parent %s in Merged dataset1' % agrandParent[ 'LogicalFileName'] print '__________________________________________________________\n\n' api.insertFileParent(aFileLFN, agrandParent['LogicalFileName']) print '****************************************************************************' print 'DELETING the parent %s from Merged dataset1' % aparentLFN print '****************************************************************************\n\n' api.deleteFileParent(aFileLFN, aparentLFN) 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() print "Done"