Hi,
Is there a better way to send reports with system.report.executeAndDistribute() at a specified time through tag event scripting?
This uses time.sleep and waits until ‘work hours’ to send the report.
hourOfDay = system.date.getHour24(system.date.now())
minuteOfHour = system.date.getMinute(system.date.now())
floatOfDay = hourOfDay + minuteOfHour / 60.0
print floatOfDay
#start time at hour 7, end time at hour 17
workStartHour = 7.0
workEndHour = 17.0
if floatOfDay < workStartHour or floatOfDay > workEndHour:
from time import sleep
diffTime = workStartHour-floatOfDay
if diffTime > 0:
hoursTillWork = diffTime * 60 * 60 #convert to seconds
print 'y'
else:
hoursTillWork = (24 + diffTime) * 60 * 60
print 'x'
sleep(hoursTillWork)
print 'a', hoursTillWork
#generate report after waiting
#system.report.executeAndDistribute()
else:
print 'b'
#generate report now
#system.report.executeAndDistribute()
Just making sure this isn’t using unnecessary overhead.