ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DATATRANSFER/searchBlockFromList.py
Revision: 1.1
Committed: Fri May 13 20:03:32 2011 UTC (13 years, 11 months ago) by fmoscato
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Log Message:
script that controll if a replica is the whole dataset or only block

File Contents

# Content
1 ########################################
2 ## author: fmoscato
3 ##############################################
4
5
6 #!/bin/python
7 import sys
8
9 Usage = """
10 script that print out replica that are only block and not the whole datasets
11 searchBlockFromList.py
12 Options:
13 --input_file file that has to be the output of checkCustodialLocation.py
14 --site site that you want to check if it was blocks
15 """
16
17
18
19 def loadData(input_file,site):
20
21 fs=open(input_file,"r")
22 lines =fs.readlines()
23 fs.close()
24 no_replica=[]
25 for f in lines:
26 ar=f.split()
27 num_custodial=None
28 num_non_custodial=None
29 custodial=ar[ar.index("custodial:")+1].split(",")
30 non_custodial=ar[ar.index("non-custodial:")+1].split(",")
31 if len(custodial):
32 try:
33 num_custodial=int((custodial[0])[custodial[0].find("(")+1:len(custodial[0])-1])
34 except:
35 print "%s no custodial location" %ar[ar.index("dataset:")+1]
36 continue
37
38 for nc in non_custodial:
39 if nc.find(site) != -1:
40 num_non_custodial=int((nc)[nc.find("(")+1:len(nc)-1])
41 if num_custodial != num_non_custodial:
42 print "check dataset %s" %ar[ar.index("dataset:")+1]
43 break
44
45
46
47
48 def main(opts, args):
49
50 input_file=''
51 site=''
52
53 for opt, val in opts:
54 if opt=='--input_file':
55 input_file = val
56 if opt=='--site':
57 site = val
58
59 if not input_file or not site:
60 print Usage
61 sys.exit(1)
62
63 loadData(input_file,site)
64
65 if __name__ == '__main__':
66 import sys
67 import getopt
68
69 try:
70 opts, args = getopt.getopt(sys.argv[1:], "", ["input_file=","site="])
71 except getopt.GetoptError, msg:
72 print
73 print msg
74 print
75 print Usage
76 sys.exit(1)
77
78 if len(opts) <1 :
79 print
80 print Usage
81 sys.exit(1)
82
83
84 main( opts, args)
85