Use render_servers instead of render_template

* limit to one output file for all virtual servers
This commit is contained in:
Thor77 2016-11-22 23:04:18 +01:00
parent 5915664605
commit 42796be9d8
1 changed files with 10 additions and 15 deletions

View File

@ -8,7 +8,7 @@ from os.path import abspath, exists
from tsstats import config from tsstats import config
from tsstats.exceptions import InvalidConfiguration from tsstats.exceptions import InvalidConfiguration
from tsstats.log import parse_logs from tsstats.log import parse_logs
from tsstats.template import render_template from tsstats.template import render_servers
logger = logging.getLogger('tsstats') logger = logging.getLogger('tsstats')
@ -82,23 +82,18 @@ def main(configuration):
if not log: if not log:
raise InvalidConfiguration('log or output missing') raise InvalidConfiguration('log or output missing')
sid_clients = parse_logs( servers = parse_logs(
log, ident_map=identmap, log, ident_map=identmap,
online_dc=configuration.getboolean('General', 'onlinedc') online_dc=configuration.getboolean('General', 'onlinedc')
) )
for sid, clients in sid_clients: render_servers(
if sid and len(sid_clients) > 1: servers,
ext = '.{}'.format(sid) output=abspath(configuration.get('General', 'output')),
else: template=configuration.get('General', 'template'),
ext = '' datetime_fmt=configuration.get('General', 'datetimeformat'),
render_template( onlinetime_threshold=int(configuration.get(
clients, 'General', 'onlinetimethreshold'))
output=abspath(configuration.get('General', 'output') + ext), )
template=configuration.get('General', 'template'),
datetime_fmt=configuration.get('General', 'datetimeformat'),
onlinetime_threshold=int(configuration.get(
'General', 'onlinetimethreshold'))
)
if __name__ == '__main__': if __name__ == '__main__':