"characteristic >= 14.0.0", # latest service-identity depends on this version
"pyasn1 >= 0.1.8", # latest pyasn1-modules depends on this version
"pyasn1-modules >= 0.0.5", # service-identity depends on this
-
- "humanize >= 0.5.1", # might not *need* to be this new
]
# We no longer have any setup dependencies.
('service-identity', 'service_identity'),
('characteristic', 'characteristic'),
('pyasn1-modules', 'pyasn1_modules'),
- ('humanize', 'humanize'),
]
# Dependencies for which we don't know how to get a version number at run-time.
not_import_versionable = [
'zope.interface',
- 'humanize',
]
# Dependencies reported by pkg_resources that we can safely ignore.
from cStringIO import StringIO
from datetime import datetime
-import humanize
import simplejson
from twisted.python import usage
from allmydata.util import fileutil
from allmydata.util import configutil
from allmydata import uri
+from allmydata.util.abbreviate import abbreviate_space, abbreviate_time
INVITE_SEPARATOR = "+"
paddedname = (' ' * (longest - len(item['path']))) + item['path']
if 'failure_at' in item:
ts = datetime.fromtimestamp(item['started_at'])
- prog = 'Failed %s (%s)' % (humanize.naturaltime(now - ts), ts)
+ prog = 'Failed %s (%s)' % (abbreviate_time(now - ts), ts)
elif item['percent_done'] < 100.0:
if 'started_at' not in item:
prog = 'not yet started'
time_left = (100.0 - item['percent_done']) / rate
prog = '%2.1f%% done, around %s left' % (
item['percent_done'],
- humanize.naturaldelta(time_left),
+ abbreviate_time(time_left),
)
else:
time_left = None
keyname = verb + '_at'
if keyname in item:
when = datetime.fromtimestamp(item[keyname])
- prog = '%s %s' % (verb, humanize.naturaltime(now - when))
+ prog = '%s %s' % (verb, abbreviate_time(now - when))
break
print " %s: %s" % (paddedname, prog)
size = meta['size']
created = datetime.fromtimestamp(meta['metadata']['tahoe']['linkcrtime'])
version = meta['metadata']['version']
- nice_size = humanize.naturalsize(size)
- nice_created = humanize.naturaltime(now - created)
+ nice_size = abbreviate_space(size)
+ nice_created = abbreviate_time(now - created)
if captype != 'filenode':
print "%20s: error, should be a filecap" % name
continue
size = meta['size']
created = datetime.fromtimestamp(meta['metadata']['tahoe']['linkcrtime'])
version = meta['metadata']['version']
- nice_size = humanize.naturalsize(size)
- nice_created = humanize.naturaltime(now - created)
+ nice_size = abbreviate_space(size)
+ nice_created = abbreviate_time(now - created)
print " %s (%s): %s, version=%s, created %s" % (n, nice_size, status, version, nice_created)
with open(os.path.join(nodedir, u'private', u'api_auth_token'), 'rb') as f:
import re
+from datetime import timedelta
HOUR = 3600
DAY = 24*3600
YEAR = 365*DAY
def abbreviate_time(s):
+ postfix = ''
+ if isinstance(s, timedelta):
+ s = s.total_seconds()
+ if s >= 0.0:
+ postfix = ' ago'
+ else:
+ postfix = ' in the future'
def _plural(count, unit):
count = int(count)
if count == 1:
- return "%d %s" % (count, unit)
- return "%d %ss" % (count, unit)
+ return "%d %s%s" % (count, unit, postfix)
+ return "%d %ss%s" % (count, unit, postfix)
if s is None:
return "unknown"
if s < 120: