Untitled diff
72 removals
90 lines
90 additions
105 lines
import glob, time, pprint
import glob, time, pprint
a = glob.glob('*.txt')[:1]
a = glob.glob('*.txt')[:1]
debug = True #tudo
debug2 = False #tela
debug3 = False #bateria
def postar_bonito(kk):
def postar_bonito(kk):
l = []
l = []
x = kk.splitlines()
x = kk.splitlines()
for k in x:
for k in x:
m, o = k.split(' - ')
m, o = k.split(' - ')
o = time.strftime('%d/%m/%Y - %H:%M:%S', time.localtime(int(o)/1000))
o = time.strftime('%d/%m/%Y - %H:%M:%S', time.localtime(int(o)/1000))
if m[0].isdigit(): m += '%'
if m[0].isdigit(): m += '%'
l.append('%s - %s' % (o, m))
l.append('%s - %s' % (o, m))
return '\n'.join(l)
return '\n'.join(l)
def estava_ligado(x):
def estava_ligado(x):
m = f.index('tela desligada')
m = f.index('tela desligada')
mm = f.index('tela ligada')
mm = f.index('tela ligada')
return mm > m
return mm > m
def remover_repetidos(s):
def remover_repetidos(s):
last = 'lolcopter'
last = 'lolcopter'
k = []
k = []
for i, e in enumerate(s):
for i, e in enumerate(s):
lolcopter = e.split(' - ')[0]
lolcopter = e.split(' - ')[0]
if lolcopter != last:
if lolcopter != last:
k.append(lolcopter)
k.append(lolcopter)
last = lolcopter
last = lolcopter
return k
return k
def estava_carregando(j):
def estava_carregando(j):
lol = remover_repetidos([m for m in j.splitlines() if m[0].isdigit()])
lol = remover_repetidos([m for m in j.splitlines() if m[0].isdigit()])
return int(lol[0]) < int(lol[1])
return int(lol[0]) < int(lol[1])
def prettytime(x):
def prettytime(x):
return time.strftime('%d/%m/%Y - %H:%M:%S', time.localtime(int(x) / 1000))
return time.strftime('%d/%m/%Y - %H:%M:%S', time.localtime(int(x) / 1000))
def prettytime2(x):
def prettytime2(x):
o, k = divmod(x, 60)
o, k = divmod(x, 60)
return '%02d:%02d' % (o, k)
return '%02d:%02d' % (o, k)
def process(x, y, z):
def process(n, x, y, z):
return [z, prettytime(x), prettytime(y), prettytime2((int(y) - int(x)) / 1000)]
return [n, z, prettytime(x), prettytime(y), prettytime2((int(y) - int(x)) / 1000)]
for i in a:
for i in a:
f = file(i, 'r').read()
f = file(i, 'r').read()
carregando_tela_ligada = []
carregando_tela_ligada = []
carregando_tela_desligada = []
carregando_tela_desligada = []
descarregando_tela_ligada = []
descarregando_tela_ligada = []
descarregando_tela_desligada = []
descarregando_tela_desligada = []
carregando = estava_carregando(f)
carregando = estava_carregando(f)
tela = estava_ligado(f)
tela = estava_ligado(f)
last = None
last = None
last_percent = None
last_percent = None
for h in f.splitlines():
n = 1
g, r = h.split(' - ')
for h in f.splitlines():
g, r = h.split(' - ')
if g[0].isdigit():
if g != last_percent:
if g[0].isdigit():
if last == None:
if debug3: print 'carregando =>', carregando
last = r
if debug2: print 'tela ligada =>', tela
if carregando:
if last == None:
if tela:
last = r
carregando_tela_ligada.append(process(last, r, last_percent))
if carregando:
else:
if tela:
carregando_tela_desligada.append(process(last, r, last_percent))
if debug: print '%d - Carregando o celular com a tela ligada, %s' % (n, h)
else:
carregando_tela_ligada.append(process(n, last, r, g))
if tela:
else:
descarregando_tela_ligada.append(process(last, r, last_percent))
if debug: print '%d - Carregando o celular com a tela desligada, %s' % (n, h)
else:
carregando_tela_desligada.append(process(n, last, r, g))
descarregando_tela_desligada.append(process(last, r, last_percent))
else:
last = r
if tela:
last_percent = g
if debug: print '%d - Descarregando o celular com a tela ligada, %s' % (n, h)
descarregando_tela_ligada.append(process(n, last, r, g))
if g == "tela desligada":
else:
tela = False
if debug: print '%d - Descarregando o celular com a tela desligada, %s' % (n, h)
if g == "tela ligada":
descarregando_tela_desligada.append(process(n, last, r, g))
tela = True
last = r
if g == "descarregando bateria":
n += 1
carregando = False
if g == "carregando bateria":
if g == "tela desligada":
carregando = True
tela = False
if debug2: print 'tela desligada'
print "carregando_tela_ligada ="
if g == "tela ligada":
pprint.pprint(carregando_tela_ligada)
tela = True
print "carregando_tela_desligada ="
if debug2: print 'tela ligada'
pprint.pprint(carregando_tela_desligada)
if g == "descarregando bateria":
print "descarregando_tela_ligada ="
carregando = False
pprint.pprint(descarregando_tela_ligada)
if debug3: print 'descarregando'
print "descarregando_tela_desligada ="
if g == "carregando bateria":
pprint.pprint(descarregando_tela_desligada)
carregando = True
if debug3: print 'carregando lol'
if debug:
print "carregando_tela_ligada ="
pprint.pprint(carregando_tela_ligada)
print "carregando_tela_desligada ="
pprint.pprint(carregando_tela_desligada)
print "descarregando_tela_ligada ="
pprint.pprint(descarregando_tela_ligada)
print "descarregando_tela_desligada ="
pprint.pprint(descarregando_tela_desligada)