diff options
author | Christian Pointner <equinox@spreadspace.org> | 2014-10-20 07:20:19 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2014-10-20 07:20:19 +0200 |
commit | b806accaa3a808cdba163d61c4c9c6c85eb6f09b (patch) | |
tree | 8200adfaa6a0895cffe8527edfee31c72f493d89 /src/daq/accesslog/s5-accesslog.py | |
parent | dag: accesslog importer can now import multiple streamerids in one pass (diff) |
daq: accesslog importer is now aligned as well
Diffstat (limited to 'src/daq/accesslog/s5-accesslog.py')
-rwxr-xr-x | src/daq/accesslog/s5-accesslog.py | 11 |
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) |