From 08a54d5d1d0441a43a995c830968e4b88a90e783 Mon Sep 17 00:00:00 2001 From: ziirish Date: Mon, 8 Feb 2016 22:44:44 +0100 Subject: [PATCH] let the API handle time conversion --- burpui/misc/backend/burp1.py | 9 ++++----- burpui/misc/backend/burp2.py | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/burpui/misc/backend/burp1.py b/burpui/misc/backend/burp1.py index 8c7d7468..984d25a1 100644 --- a/burpui/misc/backend/burp1.py +++ b/burpui/misc/backend/burp1.py @@ -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'] diff --git a/burpui/misc/backend/burp2.py b/burpui/misc/backend/burp2.py index a30b894e..93d764c9 100644 --- a/burpui/misc/backend/burp2.py +++ b/burpui/misc/backend/burp2.py @@ -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