Merge branch 'formatted_time' into develop

This commit is contained in:
Neil Booth 2016-11-19 15:42:33 +09:00
commit ab1b2be3b5
3 changed files with 10 additions and 10 deletions

View File

@ -37,6 +37,14 @@ class cachedproperty(object):
return value
def formatted_time(t):
'''Return a number of seconds as a string in days, hours, mins and
secs.'''
t = int(t)
return '{:d}d {:02d}h {:02d}m {:02d}s'.format(
t // 86400, (t % 86400) // 3600, (t % 3600) // 60, t % 60)
def deep_getsizeof(obj):
"""Find the memory footprint of a Python object.

View File

@ -21,7 +21,7 @@ from functools import partial
from server.daemon import Daemon, DaemonError
from server.version import VERSION
from lib.hash import hash_to_str
from lib.util import chunks, LoggedClass
from lib.util import chunks, formatted_time, LoggedClass
import server.db
from server.storage import open_db
@ -30,14 +30,6 @@ HIST_ENTRIES_PER_KEY = 1024
HIST_VALUE_BYTES = HIST_ENTRIES_PER_KEY * 4
def formatted_time(t):
'''Return a number of seconds as a string in days, hours, mins and
secs.'''
t = int(t)
return '{:d}d {:02d}h {:02d}m {:02d}s'.format(
t // 86400, (t % 86400) // 3600, (t % 3600) // 60, t % 60)
class ChainError(Exception):
pass

View File

@ -15,7 +15,7 @@ from struct import pack, unpack
from bisect import bisect_right
from collections import namedtuple
from lib.util import chunks, LoggedClass
from lib.util import chunks, formatted_time, LoggedClass
from lib.hash import double_sha256, hash_to_str
from server.storage import open_db
from server.version import VERSION