ATLAS Offline Software
subproc.py
Go to the documentation of this file.
1 #!/bin/env python2.5
2 #
3 # ----------------------------------------------------------------
4 # Script : subproc.py
5 # Project: AtlRunQuery
6 # Purpose: Executable for python subprocesses
7 # Authors: Andreas Hoecker (CERN), Joerg Stelzer (DESY)
8 # Created: Nov 12, 2009
9 # ----------------------------------------------------------------
10 #
11 
12 import subprocess
13 import time
14 import sys
15 import os.path
16 
17 if __name__ == '__main__':
18 
19  subtype = 'caf'
20  argstr = ''
21  if len(sys.argv)>1: subtype = sys.argv[1]
22  if len(sys.argv)>2: argstr = sys.argv[2]
23 
24  # start python subprocess to find files on CAF ---------
25  # first check age of reference file, reload if older than 1d
26  if subtype == 'caf':
27  reffile = 'data/atlas.atlcal.last'
28  if not os.path.isfile(reffile) or (time.time()-os.path.getmtime(reffile))/3600.>24.:
29  subprocess.Popen('wget -o data/wget.log http://castor.web.cern.ch/castor/DiskPoolDump/atlas.atlcal.last -O %s' % (reffile), shell=True).wait()
30 
31  dsnamesAndAge = argstr.split(',')
32  agrs = []
33  for dsnameAndAge in dsnamesAndAge:
34  # format is: '<dsname>@<age_in_sec>'
35  dsname, sep, age = dsnameAndAge.partition('@')
36  subprocess.Popen('python2.5 grepfile.py %s %s %s' % (dsname, age, reffile), shell=True)
37