Add configurable html-title
This commit is contained in:
parent
26c518ddfe
commit
e1fd6ae6f6
|
@ -11,12 +11,14 @@ Run `tsstats.py` and point your web-server to the generated .html-file, now you
|
||||||
###Sections
|
###Sections
|
||||||
`[General]`
|
`[General]`
|
||||||
### Keys
|
### Keys
|
||||||
|
- title `HTMl-Title`
|
||||||
- logfile `Path to TS3Server-logfile`
|
- logfile `Path to TS3Server-logfile`
|
||||||
- outputfile `Path to the location, where the generator will put the generated .html-file`
|
- outputfile `Path to the location, where the generator will put the generated .html-file`
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
```
|
```
|
||||||
[General]
|
[General]
|
||||||
|
title = TeamspeakStats
|
||||||
logfile = /usr/local/bin/teamspeak-server/logs/ts3server_2015-03-02__14_01_43.110983_1.log
|
logfile = /usr/local/bin/teamspeak-server/logs/ts3server_2015-03-02__14_01_43.110983_1.log
|
||||||
outputfile = /var/www/html/stats.html
|
outputfile = /var/www/html/stats.html
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<title>{{ title }}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{# Onlinetime #}
|
{# Onlinetime #}
|
||||||
|
|
|
@ -18,10 +18,11 @@ path += '/'
|
||||||
# parse config
|
# parse config
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(path + 'config.ini')
|
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!')
|
print('Invalid configuration!')
|
||||||
import sys
|
import sys
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
title = config['General']['title']
|
||||||
log_path = config['General']['logfile']
|
log_path = config['General']['logfile']
|
||||||
output_path = config['General']['outputfile']
|
output_path = config['General']['outputfile']
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ def render_template():
|
||||||
onlinetime_desc[idx] = (clid, nick, onlinetime_str, clients[clid]['connected'])
|
onlinetime_desc[idx] = (clid, nick, onlinetime_str, clients[clid]['connected'])
|
||||||
|
|
||||||
with open(output_path, 'w+') as f:
|
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:
|
if len(clients) < 1:
|
||||||
print('Not enough data!')
|
print('Not enough data!')
|
||||||
|
|
Loading…
Reference in New Issue