00001
00002
00003 from GaudiPython.GaudiAlgs import GaudiAlgo
00004 from GaudiPython import SUCCESS, FAILURE, Bindings, gbl
00005 import ROOT
00006
00007 class PollFileStatSvc(GaudiAlgo):
00008 def __init__(self,name='PollFileStatSvc'):
00009 GaudiAlgo.__init__(self,name)
00010 self.fss = None
00011 self.closed = []
00012 self.opened = []
00013 return
00014
00015 def initialize(self):
00016 self.fss = self.svc('IRootIOFileStateSvc','RootIOFileStateSvc')
00017 return SUCCESS
00018
00019 def _listify(self,vector):
00020 l = []
00021 siz = vector.size()
00022 print siz
00023 for ind in range(siz):
00024 l.append(vector[ind])
00025 return l
00026
00027 def execute(self):
00028 closed = self._listify(self.fss.closedOutput())
00029 opened = self._listify(self.fss.openOutput())
00030
00031 for fn in closed:
00032 if fn not in self.closed:
00033 print 'Got new closed file:',fn
00034 self.closed.append(fn)
00035 pass
00036 continue
00037
00038 for fn in opened:
00039 if fn not in self.opened:
00040 print 'Got new opened file:',fn
00041 pass
00042 continue
00043 self.opened = opened
00044
00045 return SUCCESS
00046
00047 def configure(argv=None):
00048 from RootIOSvc.RootIOSvcConf import RootIOFileStateSvc
00049 fss = RootIOFileStateSvc()
00050
00051 from Gaudi.Configuration import ApplicationMgr
00052 theApp = ApplicationMgr()
00053 theApp.ExtSvc.append(fss)
00054
00055 def run(app):
00056 alg = PollFileStatSvc()
00057 app.addAlgorithm(alg)
00058