143 url =
'http://atlas-ddv.cern.ch:8089/multidata/getDataSafely'
144 url2 =
'http://atlas-ddv.cern.ch:8089/multidata/downloadTxtData'
147 defaultPath = os.path.expanduser(
148 '/eos/atlas/user/j/jdickins/Pixel/LeakageCurrent/')
151 dataFolder = defaultPath +
"/IBLData/rawData/"
154 if not os.path.exists(dataFolder):
157 if not os.path.exists(dataFolder+dataType):
158 os.mkdir(dataFolder+dataType)
160 [startDates, endDates] =
checkDates(dataType, dataFolder)
161 currentDay = date.today()
162 firstDay = endDates[0].
date()-timedelta(days=1)
171 if firstDay+timedelta(days=1) < currentDay:
172 for s, e
in perdelta(firstDay, currentDay, timedelta(days=1)):
173 if not os.path.exists(dataFolder+dataType+
'/'):
174 os.mkdir(dataFolder+dataType+
'/')
176 if not os.path.exists(dataFolder+dataType+
'Stave/'):
177 os.mkdir(dataFolder+dataType+
'Stave/')
179 saveFileName2 = dataFolder+dataType+
'/' + \
180 s.strftime(
"%Y_%m_%d") +
'-' + e.strftime(
"%Y_%m_%d") +
'.txt'
181 if os.path.exists(saveFileName2):
182 os.remove(saveFileName2)
184 with open(saveFileName2,
'w')
as saveFile:
188 staveString =
"stave"
189 staveLetter =
"stave"
190 letterDict = {1:
'a', 2:
'b', 3:
'c', 4:
'd', 5:
'e', 6:
'f', 7:
'g', 8:
'h',
191 9:
'i', 10:
'j', 11:
'k', 12:
'l', 13:
'm', 14:
'n'}
192 for staveNumber
in range(1, 15):
194 staveString =
"0" +
str(staveNumber)
196 staveString =
str(staveNumber)
197 staveLetter = letterDict[staveNumber]
198 if staveNumber % 2 == 1:
205 dataFolder+dataType+
'Stave/'+s.strftime(
"%Y_%m_%d") +
206 '-' + e.strftime(
"%Y_%m_%d") +
'Stave' + staveString +
208 if os.path.exists(saveFileName):
209 os.remove(saveFileName)
211 dataType2 = dataType + staveLetter
214 cmd =
'wget --post-data "queryInfo=atlas_pvssPIX, alias, LI_S' + staveString +
'_A_' + dataType2 +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
215 "%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_C_' + dataType2 +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!" ' + url +
' --output-document=' + saveFileName
220 if (os.path.getsize(saveFileName) < 300):
223 sleepTime = random.randint(30, 62)
224 time.sleep(sleepTime)
225 os.remove(saveFileName)
227 cmd =
'wget --post-data "queryInfo=atlas_pvssPIX, alias, LI_S' + staveString +
'_A_' + dataType2 +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
228 "%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_C_' + dataType2 +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!" ' + url +
' --output-document=' + saveFileName
233 if (0 < os.path.getsize(saveFileName) < 300):
236 os.remove(saveFileName)
237 print(
"bork bork at " + s.strftime(
"%Y_%m_%d") +
238 " please sign off yourself!")
241 with open(saveFileName,
'r')
as bloop:
243 if (staveNumber != 1):
244 saveFile.write(
"!!!")
248 for bloopLine
in bloop:
249 saveFile.write(bloopLine)
252 introubleMean += introuble
254 introubleCount.append(introuble)
255 sleepTime = random.randint(30, 62)
257 time.sleep(sleepTime)
259 breakThatStick =
False
261 if introubleMean > 30:
262 for checker
in range(0, 14):
263 if introubleCount[checker] < 2:
265 print(
"borkalork in stave " +
str(checker+1))
266 breakThatStick =
True
269 print(
"breaking now at " + s.strftime(
"%d-%m-%Y"))
272 firstTempDate =
min(datetime.datetime(
273 s.year, s.month, s.day, 0, 0, 0, 0), startDates[0])
274 startDates[0] = firstTempDate
276 lastTempDate =
max(datetime.datetime(
277 e.year, e.month, e.day, 0, 0, 0, 0), endDates[0])
278 endDates[0] = lastTempDate
280 with open(dataFolder+dataType+
".txt",
'w')
as datesFile:
281 datesFile.write(dataType +
" " +
str(firstTempDate) +
" " +
282 str(lastTempDate) +
"\n")
284 sleepTime = random.randint(10, 30)
285 time.sleep(sleepTime)