Merge branch 'formatted_time' into develop
This commit is contained in:
commit
ab1b2be3b5
@ -37,6 +37,14 @@ class cachedproperty(object):
|
|||||||
return value
|
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):
|
def deep_getsizeof(obj):
|
||||||
"""Find the memory footprint of a Python object.
|
"""Find the memory footprint of a Python object.
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ from functools import partial
|
|||||||
from server.daemon import Daemon, DaemonError
|
from server.daemon import Daemon, DaemonError
|
||||||
from server.version import VERSION
|
from server.version import VERSION
|
||||||
from lib.hash import hash_to_str
|
from lib.hash import hash_to_str
|
||||||
from lib.util import chunks, LoggedClass
|
from lib.util import chunks, formatted_time, LoggedClass
|
||||||
import server.db
|
import server.db
|
||||||
from server.storage import open_db
|
from server.storage import open_db
|
||||||
|
|
||||||
@ -30,14 +30,6 @@ HIST_ENTRIES_PER_KEY = 1024
|
|||||||
HIST_VALUE_BYTES = HIST_ENTRIES_PER_KEY * 4
|
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):
|
class ChainError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ from struct import pack, unpack
|
|||||||
from bisect import bisect_right
|
from bisect import bisect_right
|
||||||
from collections import namedtuple
|
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 lib.hash import double_sha256, hash_to_str
|
||||||
from server.storage import open_db
|
from server.storage import open_db
|
||||||
from server.version import VERSION
|
from server.version import VERSION
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user