let the API handle time conversion

This commit is contained in:
ziirish 2016-02-08 22:44:44 +01:00
parent 6057dda980
commit 08a54d5d1d
2 changed files with 7 additions and 9 deletions

View file

@ -12,7 +12,6 @@ import os
import socket
import time
import json
import datetime
import shutil
import subprocess
import tempfile
@ -556,7 +555,7 @@ class Burp(BUIbackend):
if reg:
found = True
if key in ['start', 'end']:
backup[key] = int(time.mktime(datetime.datetime.strptime(reg.group(1), '%Y-%m-%d %H:%M:%S').timetuple()))
backup[key] = int(reg.group(1))
elif key == 'duration':
tmp = reg.group(1).split(':')
tmp.reverse()
@ -737,10 +736,10 @@ class Burp(BUIbackend):
cli['last'] = 'never'
elif re.match(r'^\d+\s\d+\s\d+$', infos):
spl = infos.split()
cli['last'] = datetime.datetime.fromtimestamp(int(spl[2])).strftime('%Y-%m-%d %H:%M:%S')
cli['last'] = int(spl[2])
else:
spl = infos.split('\t')
cli['last'] = datetime.datetime.fromtimestamp(int(spl[len(spl) - 2])).strftime('%Y-%m-%d %H:%M:%S')
cli['last'] = int(spl[len(spl) - 2])
res.append(cli)
return res
@ -765,7 +764,7 @@ class Burp(BUIbackend):
spl = backup.split()
bkp['number'] = spl[0]
bkp['deletable'] = (spl[1] == '1')
bkp['date'] = datetime.datetime.fromtimestamp(int(spl[2])).strftime('%Y-%m-%d %H:%M:%S')
bkp['date'] = int(spl[2])
log = self.get_backup_logs(spl[0], name)
bkp['encrypted'] = log['encrypted']
bkp['received'] = log['received']

View file

@ -2,7 +2,6 @@
import re
import os
import time
import datetime
import subprocess
import codecs
import sys
@ -614,7 +613,7 @@ class Burp(Burp1):
c['last'] = 'never'
else:
infos = infos[0]
c['last'] = datetime.datetime.fromtimestamp(infos['timestamp']).strftime('%Y-%m-%d %H:%M:%S')
c['last'] = infos['timestamp']
j.append(c)
return j
@ -641,7 +640,7 @@ class Burp(Burp1):
ba['deletable'] = True
else:
ba['deletable'] = False
ba['date'] = datetime.datetime.fromtimestamp(backup['timestamp']).strftime('%Y-%m-%d %H:%M:%S')
ba['date'] = backup['timestamp']
log = self.get_backup_logs(backup['number'], name)
try:
ba['encrypted'] = log['encrypted']
@ -697,7 +696,7 @@ class Burp(Burp1):
t['gid'] = entry['gid']
t['parent'] = top
t['size'] = '{0:.1eM}'.format(_hr(entry['size']))
t['date'] = datetime.datetime.fromtimestamp(entry['mtime']).strftime('%Y-%m-%d %H:%M:%S')
t['date'] = entry['mtime']
r.append(t)
return r