Newer
Older
TB_Chris / Kepler / GangaPlugin / Lib / .svn / text-base / TbQuery.py.svn-base
  1.  
  2. from Ganga.GPIDev.Base import GangaObject
  3. from Ganga.GPIDev.Base.Proxy import GPIProxyObjectFactory
  4. from Ganga.GPIDev.Schema import *
  5.  
  6. def ListFiles( path ,extension) :
  7. import subprocess
  8. proc = subprocess.Popen(["/afs/cern.ch/project/eos/installation/0.3.15/bin/eos.select","ls",path],stdout=subprocess.PIPE)
  9. out=""
  10. err=""
  11. files = []
  12. (out,err) = proc.communicate()
  13. files = out.split('\n')
  14. output = []
  15. for f in files:
  16. if f.find(extension) != -1:
  17. output.append( path + f)
  18. return output
  19. class TbQuery( GangaObject ) :
  20. path = ""
  21. _schema = Schema(Version(1,0), {
  22. 'Month' : SimpleItem(defvalue='',doc='Testbeam period to look for data'),
  23. 'Run' : SimpleItem(defvalue=0,doc='Run to look at')
  24. } )
  25. _name = "TbQuery"
  26. _exportmethods = ['getOptions','getFiles']
  27. _category = 'query'
  28. _data = ''
  29. def getFiles(self):
  30. path = "eos/lhcb/testbeam/velo/timepix3/%s/RawData/Run%d/" %( self.Month, self.Run )
  31. return ListFiles(path,".dat")
  32. def getConfiguration(self):
  33. path = "eos/lhcb/testbeam/velo/timepix3/%s/RootFiles/Run%d/Conditions/" %(self.Month,self.Run)
  34. return ListFiles(path,".dat")
  35. _exportmethods = ['getConfiguration','getFiles']