210 url =
'http://atlas-ddv.cern.ch:8089/multidata/getDataSafely'
211 url2 =
'http://atlas-ddv.cern.ch:8089/multidata/downloadTxtData'
214 defaultPath = os.path.expanduser(
215 '/eos/atlas/user/j/jdickins/Pixel/LeakageCurrent/')
218 dataFolder = defaultPath +
"/IBLData/rawData/"
221 if not os.path.exists(dataFolder):
224 if not os.path.exists(dataFolder+dataType):
225 os.mkdir(dataFolder+dataType)
227 [startDates, endDates] =
checkDates(dataType, dataFolder)
228 currentDay = date.today()
229 firstDay = endDates[0].
date()-timedelta(days=1)
238 if firstDay+timedelta(days=1) < currentDay:
239 for s, e
in perdelta(firstDay, currentDay, timedelta(days=1)):
240 if not os.path.exists(dataFolder+dataType+
'/'):
241 os.mkdir(dataFolder+dataType+
'/')
243 if not os.path.exists(dataFolder+dataType+
'Stave/'):
244 os.mkdir(dataFolder+dataType+
'Stave/')
246 saveFileName2 = dataFolder+dataType+
'/' + \
247 s.strftime(
"%Y_%m_%d") +
'-' + e.strftime(
"%Y_%m_%d") +
'.txt'
248 if os.path.exists(saveFileName2):
249 os.remove(saveFileName2)
251 with open(saveFileName2,
'w')
as saveFile:
255 staveString =
"stave"
256 for staveNumber
in range(1, 15):
258 staveString =
"0" +
str(staveNumber)
260 staveString =
str(staveNumber)
263 saveFileName = dataFolder+dataType+
'Stave/' + \
265 "%Y_%m_%d") +
'-' + e.strftime(
"%Y_%m_%d") +
'Stave' + staveString +
'.txt'
266 if os.path.exists(saveFileName):
267 os.remove(saveFileName)
270 cmd =
'wget --post-data "queryInfo=atlas_pvssPIX, alias, LI_S' + staveString +
'_A_M1_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_A_M2_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_A_M3_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_A_M4_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
271 "%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_C_M1_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_C_M2_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_C_M3_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_C_M4_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!" ' + url +
' --output-document=' + saveFileName
276 if (os.path.getsize(saveFileName) < 300):
279 sleepTime = random.randint(30, 62)
280 time.sleep(sleepTime)
281 os.remove(saveFileName)
283 cmd =
'wget --post-data "queryInfo=atlas_pvssPIX, alias, LI_S' + staveString +
'_A_M1_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_A_M2_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_A_M3_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_A_M4_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
284 "%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_C_M1_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_C_M2_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_C_M3_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!atlas_pvssPIX, alias, LI_S' + staveString +
'_C_M4_' + dataType +
', ' + s.strftime(
"%d-%m-%Y") +
' 00:00, ' + e.strftime(
"%d-%m-%Y") +
' 00:01, , , , , ,no, , +2!!" ' + url2 +
' --output-document=' + saveFileName
289 if (0 < os.path.getsize(saveFileName) < 300):
292 os.remove(saveFileName)
293 print(
"bork bork at " + s.strftime(
"%Y_%m_%d") +
294 " please sign off yourself!")
297 with open(saveFileName,
'r')
as bloop:
299 if (staveNumber != 1):
300 saveFile.write(
"!!!")
304 for bloopLine
in bloop:
305 saveFile.write(bloopLine)
308 introubleMean += introuble
310 introubleCount.append(introuble)
311 sleepTime = random.randint(30, 62)
313 time.sleep(sleepTime)
315 breakThatStick =
False
317 if introubleMean > 30:
318 for checker
in range(0, 14):
319 if introubleCount[checker] < 2:
321 print(
"borkalork in stave " +
str(checker+1))
322 breakThatStick =
True
325 print(
"breaking now at " + s.strftime(
"%d-%m-%Y"))
328 firstTempDate =
min(datetime.datetime(
329 s.year, s.month, s.day, 0, 0, 0, 0), startDates[0])
330 startDates[0] = firstTempDate
332 lastTempDate =
max(datetime.datetime(
333 e.year, e.month, e.day, 0, 0, 0, 0), endDates[0])
334 endDates[0] = lastTempDate
336 with open(dataFolder+dataType+
".txt",
'w')
as datesFile:
337 datesFile.write(dataType +
" " +
str(firstTempDate) +
" " +
338 str(lastTempDate) +
"\n")
340 sleepTime = random.randint(10, 30)
341 time.sleep(sleepTime)