Browse Source

Move formatted_time to library

master
Neil Booth 8 years ago
parent
commit
3d87e299ea
  1. 8
      lib/util.py
  2. 10
      server/block_processor.py
  3. 2
      server/db.py

8
lib/util.py

@ -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.

10
server/block_processor.py

@ -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

2
server/db.py

@ -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

Loading…
Cancel
Save