1 |
|
2 |
import dbsclient
|
3 |
|
4 |
client = dbsclient.DBSClient()
|
5 |
def stringp(inStr) :
|
6 |
return client.str(inStr)
|
7 |
|
8 |
def delStringp(inStr) :
|
9 |
dbsclient.delete_stringp(inStr)
|
10 |
|
11 |
def string(key) :
|
12 |
return dbsclient.ASTR(key)
|
13 |
|
14 |
def integer(key) :
|
15 |
return dbsclient.AINT(key)
|
16 |
|
17 |
def character(key) :
|
18 |
return dbsclient.ACHR(key)
|
19 |
|
20 |
def setStrValue(aRow, key, value) :
|
21 |
if(value != None and key != None):
|
22 |
key = stringp(key)
|
23 |
aRow.setValue(key, string(value))
|
24 |
delStringp(key)
|
25 |
|
26 |
def setIntValue(aRow, key, value) :
|
27 |
key = stringp(key)
|
28 |
aRow.setValue(key, integer(int(value)))
|
29 |
delStringp(key)
|
30 |
|
31 |
def setChrValue(aRow, key, value) :
|
32 |
key = stringp(key)
|
33 |
aRow.setValue(key, character(value))
|
34 |
delStringp(key)
|
35 |
|
36 |
def getStrValue(table, key, index) :
|
37 |
if(index != None and key != None):
|
38 |
if(index > -1) :
|
39 |
key = stringp(key)
|
40 |
value = table.getStrValue(index, key)
|
41 |
delStringp(key)
|
42 |
return value
|
43 |
def writeFile():
|
44 |
|
45 |
table = dbsclient.FileviewMultiTable()
|
46 |
aRow = dbsclient.Fileviewmultirow()
|
47 |
fileVector = dbsclient.FileVector()
|
48 |
|
49 |
setStrValue(aRow, "t_file_status.name", "afile")
|
50 |
setStrValue(aRow, "t_file.guid", "Test-1234-Guid")
|
51 |
setStrValue(aRow, "t_file.checksum", "1234")
|
52 |
setStrValue(aRow, "t_file.logical_name", "afilexgetLogicalFileNamex")
|
53 |
setIntValue(aRow, "t_file.inblock", 10)
|
54 |
setStrValue(aRow, "t_file_type.name", "ROOT_All")
|
55 |
setStrValue(aRow, "t_file.filesize", "sucks")
|
56 |
setIntValue(aRow, "t_evcoll_file.evcoll", 1840)
|
57 |
fileVector.push_back(aRow)
|
58 |
|
59 |
aRow1 = dbsclient.Fileviewmultirow()
|
60 |
setStrValue(aRow1, "t_file_status.name", "afile")
|
61 |
setStrValue(aRow1, "t_file.guid", "Test-1234-Guid")
|
62 |
setStrValue(aRow1, "t_file.checksum", "1234")
|
63 |
setStrValue(aRow1, "t_file.logical_name", "afilexgetLogicalFileNamexy")
|
64 |
setIntValue(aRow1, "t_file.inblock", 10)
|
65 |
setStrValue(aRow1, "t_file_type.name", "ROOT_All")
|
66 |
setStrValue(aRow1, "t_file.filesize", "sucks")
|
67 |
setIntValue(aRow1, "t_evcoll_file.evcoll", 1840)
|
68 |
fileVector.push_back(aRow1)
|
69 |
|
70 |
client.insertFiles(fileVector, table)
|
71 |
|
72 |
def readFilesByBlock():
|
73 |
|
74 |
aRow = dbsclient.Fileviewmultirow()
|
75 |
table = dbsclient.FileviewMultiTable()
|
76 |
|
77 |
setIntValue(aRow, "t_evcoll_file.evcoll", 1)
|
78 |
setIntValue(aRow, "t_file.inblock", 1)
|
79 |
|
80 |
client.readFiles(aRow, table)
|
81 |
|
82 |
noOfRows = table.getNoOfRows()
|
83 |
print "no of Rows ",noOfRows
|
84 |
for j in range(noOfRows) :
|
85 |
fileStatus = getStrValue(table, "t_file_status.name", j)
|
86 |
print "fileStatus", fileStatus
|
87 |
guid = getStrValue(table, "t_file.guid", j)
|
88 |
print "guid", guid
|
89 |
logicalFileName = getStrValue(table, "t_file.logical_name", j)
|
90 |
print "logicalFileName", logicalFileName
|
91 |
fileBlockId = getStrValue(table, "t_file.inblock", j)
|
92 |
print "inblock", fileBlockId
|
93 |
fileType = getStrValue(table, "t_file_type.name", j)
|
94 |
print "fileType", fileType
|
95 |
fileSize = getStrValue(table, "t_file.filesize", j)
|
96 |
print "fileSize", fileSize
|
97 |
|
98 |
table.dispose()
|
99 |
|
100 |
|
101 |
def writePrimary() :
|
102 |
aRow = dbsclient.Primarydatasetmultirow()
|
103 |
table = dbsclient.PrimarydatasetMultiTable()
|
104 |
|
105 |
setStrValue(aRow, "t_desc_mc.description", "dummy_value")
|
106 |
setStrValue(aRow, "t_desc_trigger.description", "t_desc_trigger.descriptiondummy_value")
|
107 |
setStrValue(aRow, "t_desc_mc.decay_chain", "dummyt_desc_mc.decay_chain")
|
108 |
setStrValue(aRow, "t_desc_mc.production", "dummyt_desc_mc.production")
|
109 |
setStrValue(aRow, "t_primary_dataset.name", "DUMMYNAME")
|
110 |
setChrValue(aRow, "t_desc_primary.is_mc_data", "y")
|
111 |
|
112 |
a = client.createPrimaryDataset(aRow, table)
|
113 |
print "ID is ",a
|
114 |
#key = stringp("t_primary_dataset.id")
|
115 |
#print "table.getStrValue ", table.getStrValue(0,key)
|
116 |
#delStringp(key)
|
117 |
|
118 |
def readPrimary() :
|
119 |
aRow = dbsclient.Primarydatasetmultirow()
|
120 |
table = dbsclient.PrimarydatasetMultiTable()
|
121 |
setStrValue(aRow, "t_primary_dataset.name", "DUMMYNAME")
|
122 |
|
123 |
client.readPrimaryDataset(aRow, table)
|
124 |
noOfRows = table.getNoOfRows()
|
125 |
print "no of Rows ",noOfRows
|
126 |
for j in range(noOfRows) :
|
127 |
print "table.getStrValue", getStrValue(table, "t_primary_dataset.name", j)
|
128 |
#table.dispose()
|
129 |
|
130 |
|
131 |
def writeProcessed() :
|
132 |
aRow = dbsclient.Processingpathmultirow()
|
133 |
table = dbsclient.ProcessingpathMultiTable()
|
134 |
|
135 |
setStrValue(aRow, "t_processed_dataset.name", "dummy_valuet_processed_dataset.name")
|
136 |
setStrValue(aRow, "t_app_family.name", "dummyvaluet_app_family.name")
|
137 |
setStrValue(aRow, "t_data_tier.name", "t_data_tier.namedummy_value")
|
138 |
setStrValue(aRow, "t_application.executable", "t_application.executablemmy_value")
|
139 |
setStrValue(aRow, "t_app_config.parameter_set", "dummyt_app_config.parameter_set")
|
140 |
setChrValue(aRow, "t_processed_dataset.is_open", "y")
|
141 |
setStrValue(aRow, "t_application.app_version", "dummyt_application.app_version")
|
142 |
setStrValue(aRow, "t_app_config.conditions_version", "dummyt_app_config.conditions_version")
|
143 |
setStrValue(aRow, "t_processing_path.full_path", "dummyt_processing_path.full_path")
|
144 |
setStrValue(aRow, "t_primary_dataset.name", "t_primary_dataset.name")
|
145 |
setStrValue(aRow, "t_collection_type.name.t_application.output_type", "dummyt_collection_type.name.t_application.output_type")
|
146 |
setStrValue(aRow, "t_collection_type.name.t_application.input_type", "dummyt_collection_type.name.t_application.input_type")
|
147 |
|
148 |
a = client.createProcessedDataset(aRow, table)
|
149 |
print "ID is ",a
|
150 |
|
151 |
|
152 |
def readProcessed() :
|
153 |
aRow = dbsclient.Processingpathmultirow()
|
154 |
table = dbsclient.ProcessingpathMultiTable()
|
155 |
|
156 |
setStrValue(aRow, "t_primary_dataset.name", "t_primary_dataset.name")
|
157 |
|
158 |
client.readProcessedDataset(aRow, table)
|
159 |
noOfRows = table.getNoOfRows()
|
160 |
print "no of Rows ",noOfRows
|
161 |
for j in range(noOfRows) :
|
162 |
print "table.getStrValue", getStrValue(table, "t_primary_dataset.name", j)
|
163 |
table.dispose()
|
164 |
|
165 |
|
166 |
def writeEC() :
|
167 |
aRow = dbsclient.Processingpathmultirow()
|
168 |
table = dbsclient.ProcessingpathMultiTable()
|
169 |
|
170 |
setStrValue(aRow, "t_processed_dataset.name", "dummy_valuet_processed_dataset.name")
|
171 |
|
172 |
def readCrabEC() :
|
173 |
aRow = dbsclient.Crabevcollviewmultirow()
|
174 |
table = dbsclient.CrabevcollviewMultiTable()
|
175 |
setStrValue(aRow, "t_data_tier.name", "Digi")
|
176 |
setStrValue(aRow, "t_primary_dataset.name", "ThisIsATestDataset")
|
177 |
setStrValue(aRow, "t_processed_dataset.name", "ThisIsATestProcDataset")
|
178 |
|
179 |
|
180 |
client.readCrabEC(aRow, table)
|
181 |
noOfRows = table.getNoOfRows()
|
182 |
print "no of Rows ",noOfRows
|
183 |
for j in range(noOfRows) :
|
184 |
print "***************************************************************"
|
185 |
print "table.getStrValue", getStrValue(table, "t_info_evcoll.name", j)
|
186 |
blockId = getStrValue(table, "t_block.id", j)
|
187 |
print "blockId", blockId
|
188 |
evcollName = getStrValue(table, "t_info_evcoll.name", j)
|
189 |
print "evcollName", evcollName
|
190 |
events = getStrValue(table, "t_info_evcoll.events", j)
|
191 |
print "events", events
|
192 |
evCollId = getStrValue(table, "t_event_collection.id", j)
|
193 |
print "t_event_collection", evCollId
|
194 |
print "***************************************************************"
|
195 |
|
196 |
table.dispose()
|
197 |
|
198 |
|
199 |
while(1):
|
200 |
#for i in range(1) :
|
201 |
try:
|
202 |
readPrimary()
|
203 |
#writePrimary()
|
204 |
#writeProcessed()
|
205 |
#readProcessed()
|
206 |
#readCrabEC()
|
207 |
#writeFile()
|
208 |
#readFilesByBlock()
|
209 |
except Exception ,e:
|
210 |
print "Exception ", e
|