summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/daq/accesslog/s5-accesslog.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/daq/accesslog/s5-accesslog.py b/src/daq/accesslog/s5-accesslog.py
index 44df905..e3d846f 100755
--- a/src/daq/accesslog/s5-accesslog.py
+++ b/src/daq/accesslog/s5-accesslog.py
@@ -242,6 +242,14 @@ class AccessLog():
linedata['ts'] = self._parseDatetime(linedata['ts'])
return linedata
+ def _getTsFromLogDataAligned(self, ts):
+ try:
+ tsi = int(ts.strftime('%s'))
+ tsi = tsi - (tsi % self._duration)
+ return datetime.datetime.fromtimestamp(tsi)
+ except ValueError:
+ return ts
+
def _sendLogData(self):
linecnt = 0
updatecnt = 0
@@ -253,8 +261,7 @@ class AccessLog():
linecnt += 1
linedata = self._parseLine(regex, line)
if not lastts:
- lastts = linedata['ts']
- # TODO: make this aligned to time!
+ lastts = self._getTsFromLogDataAligned(linedata['ts'])
nextts = lastts + datetime.timedelta(seconds=self._duration)
self._clearClients()
self._updateClients(linedata)