summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/daq/nginx-lua/s5-nginx-lua-fetch.py27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/daq/nginx-lua/s5-nginx-lua-fetch.py b/src/daq/nginx-lua/s5-nginx-lua-fetch.py
index 916bb3f..e096d1e 100755
--- a/src/daq/nginx-lua/s5-nginx-lua-fetch.py
+++ b/src/daq/nginx-lua/s5-nginx-lua-fetch.py
@@ -236,13 +236,12 @@ class NGXLuaFetcher():
print 'SFive: looper started at %sZ' % (self._start_time.isoformat('T'))
def _sendUpdates(self):
- if self._connected:
- for c in self._streamer.keys():
- for f in self._streamer[c].keys():
- for q in self._streamer[c][f].keys():
+ for c in self._streamer.keys():
+ for f in self._streamer[c].keys():
+ for q in self._streamer[c][f].keys():
+ if self._connected:
self._sendDataset(self._start_time, self._duration, c, f, q)
- else:
- print 'SFive: not connected - just clearing stats'
+ self._streamer[c][f][q].clear()
self._start_time = datetime.datetime.utcnow().replace(microsecond=0)
@@ -278,22 +277,16 @@ class NGXLuaFetcher():
print 'SFive: regex error: %s' % (e)
try:
- ts = dateutil.parser.parse(data['time'])
- ts = (ts - ts.utcoffset()).replace(tzinfo=None)
- if self._start_time and ts >= self._start_time:
- print "url='%s' -> contend-id: '%s', format: '%s', quality: '%s'" % (data['url'],
- streamerid['content'], streamerid['format'], streamerid['quality'])
- print " --> %(time)s: from %(client)s/%(port)d (%(ua)s) %(status)d: %(bytes-sent)d bytes" % data
- # self._clients.update(data)
+ if data['status'] == 200 or data['status'] == 206:
+ ts = dateutil.parser.parse(data['time'])
+ ts = (ts - ts.utcoffset()).replace(tzinfo=None)
+ if self._start_time and ts >= self._start_time:
+ self._streamer[streamerid['content']][streamerid['format']][streamerid['quality']].update(data)
except KeyError as e:
print 'SFive: %s - ignoring dataset' % (e)
except ValueError as e:
print 'SFive: %s - ignoring dataset' % (e)
- except AttributeError as e:
- print 'SFive: %s - ignoring dataset' % (e)
- except TypeError as e:
- print 'SFive: %s - ignoring dataset' % (e)
def close(self):
if self._conn and self._connected: