34 if not os.environ.has_key(
'DBS_STRATEGY'):
35 os.environ[
'DBS_STRATEGY'] =
"search"
36 if not os.environ.has_key(
'DBS_RELEASE'):
37 os.environ[
'DBS_RELEASE'] =
"Any"
38 if not os.environ.has_key(
'DBS_SAMPLE'):
39 os.environ[
'DBS_SAMPLE'] =
"Any"
40 if not os.environ.has_key(
'DBS_RUN'):
41 os.environ[
'DBS_RUN'] =
"Any"
42 if not os.environ.has_key(
'DBS_TIER_SECONDARY'):
43 os.environ[
'DBS_TIER_SECONDARY'] =
""
47 if os.environ[
'DBS_STRATEGY'] ==
"local":
50 for line
in open(
'electronDbsDiscovery.txt').readlines():
51 line = os.path.expandvars(line.strip())
52 if line ==
"":
continue
53 if os.environ[
'DBS_SAMPLE'] !=
"Any" and line.find(os.environ[
'DBS_SAMPLE'])== -1:
continue
54 if line.find(os.environ[
'DBS_COND'])== -1:
continue
55 if line.find(dbs_tier)== -1:
continue
56 result.append(
'file:'+line)
58 elif os.environ[
'DBS_STRATEGY'] ==
"castor":
60 castor_dir = os.environ[
'DBS_CASTOR_DIR']
62 data = os.popen(
'rfdir /castor/cern.ch/cms'+castor_dir)
63 subdirs = data.readlines()
68 subdir = line.split()[8]
69 data = os.popen(
'rfdir /castor/cern.ch/cms'+castor_dir+
'/'+subdir)
70 datalines = data.readlines()
71 for line
in datalines:
73 file = line.split()[8]
75 result.append(castor_dir+
'/'+subdir+
'/'+file)
78 elif os.environ[
'DBS_STRATEGY'] ==
"lsf":
80 dbs_path =
'/'+os.environ[
'DBS_SAMPLE']+
'/'+os.environ[
'DBS_RELEASE']+
'-'+os.environ[
'DBS_COND']+
'/'+os.environ[
'DBS_TIER']+
'"'
81 if __name__ ==
"__main__":
82 print 'dbs path:',dbs_path
83 data = os.popen(
'dbs lsf --path="'+dbs_path+
'"')
84 datalines = data.readlines()
87 for line
in datalines:
89 if line !=
"" and line[0] ==
"/":
96 if os.environ[
'DBS_RELEASE'] !=
"Any":
97 input = input + separator +
"release = " + os.environ[
'DBS_RELEASE']
99 if os.environ[
'DBS_SAMPLE'] !=
"Any":
100 input = input + separator +
"primds = " + os.environ[
'DBS_SAMPLE']
102 if os.environ[
'DBS_RUN'] !=
"Any":
103 input = input + separator +
"run = " + os.environ[
'DBS_RUN']
105 input = input + separator +
"dataset like *" + os.environ[
'DBS_COND'] +
"*" + dbs_tier +
"*"
132 data = os.popen(
'dbs search --url="http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet" --query "'+input+
'"')
133 datalines = data.readlines()
136 for line
in datalines:
138 if line !=
"" and line[0] ==
"/":