diff options
author | Christian Pointner <equinox@spreadspace.org> | 2017-05-10 23:13:11 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2017-05-10 23:15:47 +0200 |
commit | b53f49f8cbd3b7666c9267f0e2d88fce28ae6c1a (patch) | |
tree | 5da51d292af7c5ad16a7198552f785f8cdf872f6 /src/daq/accesslog/s5-accesslog | |
parent | and one more variable refactoring (diff) |
new protocol version with streamlined names for variables
Diffstat (limited to 'src/daq/accesslog/s5-accesslog')
-rwxr-xr-x | src/daq/accesslog/s5-accesslog | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/daq/accesslog/s5-accesslog b/src/daq/accesslog/s5-accesslog index e91c523..29ec9f3 100755 --- a/src/daq/accesslog/s5-accesslog +++ b/src/daq/accesslog/s5-accesslog @@ -138,7 +138,7 @@ class AccessLog(): self._duration = properties['duration'] self._tags = properties['tags'] self._logfile = properties['logfile'] - self._initStreamerIds(properties['streamer-ids']) + self._initStreamerIds(properties['streams']) self._proto = None self._conn = None @@ -175,7 +175,7 @@ class AccessLog(): if len(cs.keys()) == 1: self._content_id = cs.keys()[0] - print 'SFive: only one content-id detected "%s" - will include it in init messages only' % self._content_id + print 'SFive: only one content detected "%s" - will include it in init messages only' % self._content_id if len(fs.keys()) == 1: self._format = fs.keys()[0] @@ -345,9 +345,9 @@ class AccessLog(): def _sendDatasetFull(self, timestamp, duration, content_id, format, quality): clients = self._streamer[content_id][format][quality] - data = { "version": 1, "hostname": self._hostname, "tags": self._tags, - "streamer-id": { - "content-id": content_id, + data = { "version": 2, "hostname": self._hostname, "tags": self._tags, + "stream": { + "content": content_id, "format": format, "quality": quality }, @@ -362,17 +362,17 @@ class AccessLog(): self._proto.sendDatagram('%s\n' % (json.dumps(data))) def _sendInit(self): - initdata = { "version": 1, "hostname": self._hostname, - "streamer-id" : { }, + initdata = { "version": 2, "hostname": self._hostname, + "stream" : { }, "tags": self._tags } if self._content_id: - initdata["streamer-id"]["content-id"] = self._content_id + initdata["stream"]["content"] = self._content_id if self._format: - initdata["streamer-id"]["format"] = self._format + initdata["stream"]["format"] = self._format if self._quality: - initdata["streamer-id"]["quality"] = self._quality - if len(initdata["streamer-id"].keys()) == 0: - del initdata["streamer-id"] + initdata["stream"]["quality"] = self._quality + if len(initdata["stream"].keys()) == 0: + del initdata["stream"] self._proto.sendDatagram('%s\n' % (json.dumps(initdata))) @@ -380,7 +380,7 @@ class AccessLog(): clients = self._streamer[content_id][format][quality] data = { "start-time": timestamp.isoformat('T') + 'Z', "duration-ms": duration * 1000, - "streamer-id": { }, + "stream": { }, "data": { "clients": list(clients.values()), "client-count": clients.getCnt(), @@ -388,13 +388,13 @@ class AccessLog(): } } if not self._content_id: - data["streamer-id"]["content-id"] = content_id + data["stream"]["content"] = content_id if not self._format: - data["streamer-id"]["format"] = format + data["stream"]["format"] = format if not self._quality: - data["streamer-id"]["quality"] = quality - if len(data["streamer-id"].keys()) == 0: - del data["streamer-id"] + data["stream"]["quality"] = quality + if len(data["stream"].keys()) == 0: + del data["stream"] self._proto.sendDatagram('%s\n' % (json.dumps(data))) @@ -411,8 +411,8 @@ if __name__ == '__main__': help='time (in seconds) between updates; defaults to 15') parser.add_argument('--tag', '-t', dest='tags', action='append', help='tag to be added to the statistic data, can be invoked several times') - parser.add_argument('--streamer-id', '-S', dest='streamer-ids', action='append', - help='a streamer description like <content-id1>[,<content-id2>]/<format1>[,<format2>]/<quality>[,<quality>[,<quality]], can be invoked several times') + parser.add_argument('--stream', '-S', dest='streams', action='append', + help='a streamer description like <content1>[,<content2>]/<format1>[,<format2>]/<quality>[,<quality>[,<quality]], can be invoked several times') parser.add_argument('--logfile', '-l', dest='logfile', required=True, help='path to the logfile or \'-\' for standard input') parser.add_argument('--nameformat', '-F', dest='nameformat', required=False, @@ -426,8 +426,8 @@ if __name__ == '__main__': args['duration'] = int(args['duration']) if not args['nameformat']: args['nameformat'] = '/[^/]+/(?P<format>hls|dash)/(?P<content>.+)-(?P<quality>[^-]+)/.*' - if not args['streamer-ids']: - print 'SFive: you have to specify at least one streamer-id!' + if not args['streams']: + print 'SFive: you have to specify at least one stream!' exit(-1) importer = AccessLog(args) importer.run() |