Add configurable html-title

This commit is contained in:
Thor77 2015-04-22 16:32:28 +02:00
parent 26c518ddfe
commit e1fd6ae6f6
3 changed files with 6 additions and 2 deletions

View File

@ -11,12 +11,14 @@ Run `tsstats.py` and point your web-server to the generated .html-file, now you
###Sections
`[General]`
### Keys
- title `HTMl-Title`
- logfile `Path to TS3Server-logfile`
- outputfile `Path to the location, where the generator will put the generated .html-file`
## Example
```
[General]
title = TeamspeakStats
logfile = /usr/local/bin/teamspeak-server/logs/ts3server_2015-03-02__14_01_43.110983_1.log
outputfile = /var/www/html/stats.html
```

View File

@ -7,6 +7,7 @@
text-align: center;
}
</style>
<title>{{ title }}</title>
</head>
<body>
{# Onlinetime #}

View File

@ -18,10 +18,11 @@ path += '/'
# parse config
config = configparser.ConfigParser()
config.read(path + 'config.ini')
if 'General' not in config or not ('logfile' in config['General'] and 'outputfile' in config['General']):
if 'General' not in config or not ('title' in config['General'] and 'logfile' in config['General'] and 'outputfile' in config['General']):
print('Invalid configuration!')
import sys
sys.exit()
title = config['General']['title']
log_path = config['General']['logfile']
output_path = config['General']['outputfile']
@ -153,7 +154,7 @@ def render_template():
onlinetime_desc[idx] = (clid, nick, onlinetime_str, clients[clid]['connected'])
with open(output_path, 'w+') as f:
f.write(template.render(onlinetime=onlinetime_desc, kicks=desc('kicks'), pkicks=desc('pkicks'), bans=desc('bans'), seconds='{}.{}'.format(generation_delta.seconds, generation_delta.microseconds), date=generation_end.strftime('%d.%m.%Y um %H:%M')))
f.write(template.render(title=title, onlinetime=onlinetime_desc, kicks=desc('kicks'), pkicks=desc('pkicks'), bans=desc('bans'), seconds='{}.{}'.format(generation_delta.seconds, generation_delta.microseconds), date=generation_end.strftime('%d.%m.%Y um %H:%M')))
if len(clients) < 1:
print('Not enough data!')