X-Git-Url: https://git.rkrishnan.org/?a=blobdiff_plain;f=src%2Fallmydata%2Fweb%2Fcommon.py;h=b8e6d5b4490395cd4fb35e0fc7756691dc86e2e7;hb=6226f6b497028889859dfcff56d4dbd7b65b8c2c;hp=52fed6a04be4c0002a52acc7e546380b5abfe5d4;hpb=6d4a8bcd7f4af289e95195a2090c95b79a43ef59;p=tahoe-lafs%2Ftahoe-lafs.git diff --git a/src/allmydata/web/common.py b/src/allmydata/web/common.py index 52fed6a0..b8e6d5b4 100644 --- a/src/allmydata/web/common.py +++ b/src/allmydata/web/common.py @@ -1,5 +1,7 @@ +import time import simplejson + from twisted.web import http, server from twisted.python import log from zope.interface import Interface @@ -13,11 +15,10 @@ from allmydata.interfaces import ExistingChildError, NoSuchChildError, \ MustBeReadonlyError, MustNotBeUnknownRWError, SDMF_VERSION, MDMF_VERSION from allmydata.mutable.common import UnrecoverableFileError from allmydata.util import abbreviate +from allmydata.util.time_format import format_time from allmydata.util.encodingutil import to_str, quote_output -TIME_FORMAT = "%H:%M:%S %d-%b-%Y" - def get_filenode_metadata(filenode): metadata = {'mutable': filenode.is_mutable()} if metadata['mutable']: @@ -209,6 +210,12 @@ def text_plain(text, ctx): req.setHeader("content-length", b"%d" % len(text)) return text +def spaces_to_nbsp(text): + return unicode(text).replace(u' ', u'\u00A0') + +def render_time(t): + return spaces_to_nbsp(format_time(time.localtime(t))) + class WebError(Exception): def __init__(self, text, code=http.BAD_REQUEST): self.text = text