Use pendulum for creation_time

This commit is contained in:
Thor77 2017-05-20 00:59:40 +02:00
parent 679b84eb79
commit c7e89a2ee2
1 changed files with 4 additions and 6 deletions

View File

@ -2,14 +2,13 @@
import logging import logging
from collections import namedtuple from collections import namedtuple
from datetime import datetime
from os.path import dirname, join from os.path import dirname, join
import pendulum
from jinja2 import ChoiceLoader, Environment, FileSystemLoader, PackageLoader from jinja2 import ChoiceLoader, Environment, FileSystemLoader, PackageLoader
from tsstats.log import Server from tsstats.log import Server
from tsstats.utils import (filter_threshold, seconds_to_text, sort_clients, from tsstats.utils import filter_threshold, seconds_to_text, sort_clients
tz_aware_datime)
logger = logging.getLogger('tsstats') logger = logging.getLogger('tsstats')
@ -43,8 +42,7 @@ def prepare_clients(clients, onlinetime_threshold=-1):
clients, lambda c: c.onlinetime.total_seconds() clients, lambda c: c.onlinetime.total_seconds()
) )
# filter clients not matching threshold # filter clients not matching threshold
onlinetime_ = filter_threshold(onlinetime_, onlinetime_ = filter_threshold(onlinetime_, onlinetime_threshold)
onlinetime_threshold)
# convert timespans to text # convert timespans to text
onlinetime = [ onlinetime = [
(client, seconds_to_text(int(onlinetime))) (client, seconds_to_text(int(onlinetime)))
@ -105,6 +103,6 @@ def render_servers(servers, output, title='TeamspeakStats',
logger.debug('Rendering template %s', template) logger.debug('Rendering template %s', template)
template.stream(title=title, servers=prepared_servers, template.stream(title=title, servers=prepared_servers,
debug=logger.level <= logging.DEBUG, debug=logger.level <= logging.DEBUG,
creation_time=tz_aware_datime(datetime.utcnow()))\ creation_time=pendulum.utcnow())\
.dump(output, encoding='utf-8') .dump(output, encoding='utf-8')
logger.debug('Wrote rendered template to %s', output) logger.debug('Wrote rendered template to %s', output)