added hh mm ss localization (fix )

This commit is contained in:
Simone Margaritelli 2019-10-04 19:03:33 +02:00
parent 3c3ae2b30b
commit 22f06df0a3
3 changed files with 28 additions and 7 deletions
sdcard/rootfs/root/pwnagotchi/scripts
main.py
pwnagotchi

@ -46,7 +46,7 @@ if args.do_clear:
elif args.do_manual: elif args.do_manual:
logging.info("entering manual mode ...") logging.info("entering manual mode ...")
log = SessionParser(config['main']['log']) log = SessionParser(config)
logging.info( logging.info(
"the last session lasted %s (%d completed epochs, trained for %d), average reward:%s (min:%s max:%s)" % ( "the last session lasted %s (%d completed epochs, trained for %d), average reward:%s (min:%s max:%s)" % (
log.duration_human, log.duration_human,

@ -186,3 +186,22 @@ msgid ""
"{associated} new friends and ate {handshakes} handshakes! #pwnagotchi " "{associated} new friends and ate {handshakes} handshakes! #pwnagotchi "
"#pwnlog #pwnlife #hacktheplanet #skynet" "#pwnlog #pwnlife #hacktheplanet #skynet"
msgstr "" msgstr ""
msgid "hours"
msgstr ""
msgid "hour"
msgstr ""
msgid "minutes"
msgstr ""
msgid "minute"
msgstr ""
msgid "hours"
msgstr ""
msgid "hour"
msgstr ""

@ -1,10 +1,10 @@
import os
import hashlib import hashlib
import time import time
import re import re
import os import os
from datetime import datetime from datetime import datetime
from pwnagotchi.voice import Voice
from pwnagotchi.mesh.peer import Peer from pwnagotchi.mesh.peer import Peer
from file_read_backwards import FileReadBackwards from file_read_backwards import FileReadBackwards
@ -125,17 +125,19 @@ class SessionParser(object):
self.duration = '%02d:%02d:%02d' % (hours, mins, secs) self.duration = '%02d:%02d:%02d' % (hours, mins, secs)
self.duration_human = [] self.duration_human = []
if hours > 0: if hours > 0:
self.duration_human.append('%d hours' % hours) self.duration_human.append('%d %s' % (hours, self.voice.custom('hours' if hours > 1 else 'hour')))
if mins > 0: if mins > 0:
self.duration_human.append('%d minutes' % mins) self.duration_human.append('%d %s' % (mins, self.voice.custom('minutes' if mins > 1 else 'minute')))
if secs > 0: if secs > 0:
self.duration_human.append('%d seconds' % secs) self.duration_human.append('%d %s' % (secs, self.voice.custom('seconds' if secs > 1 else 'second')))
self.duration_human = ', '.join(self.duration_human) self.duration_human = ', '.join(self.duration_human)
self.avg_reward /= (self.epochs if self.epochs else 1) self.avg_reward /= (self.epochs if self.epochs else 1)
def __init__(self, path='/var/log/pwnagotchi.log'): def __init__(self, config):
self.path = path self.config = config
self.voice = Voice(lang=config['main']['lang'])
self.path = config['main']['log']
self.last_session = None self.last_session = None
self.last_session_id = '' self.last_session_id = ''
self.last_saved_session_id = '' self.last_saved_session_id = ''