From: Brian Warner Date: Mon, 15 Sep 2008 20:43:14 +0000 (-0700) Subject: webish: add an extra newline to JSON output X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/%22doc.html/copyable.html?a=commitdiff_plain;h=51612cd1beb7cdf5d5e1e5707905d1200ecbe783;p=tahoe-lafs%2Ftahoe-lafs.git webish: add an extra newline to JSON output --- diff --git a/src/allmydata/web/checker_results.py b/src/allmydata/web/checker_results.py index 80251c2c..e82e63b8 100644 --- a/src/allmydata/web/checker_results.py +++ b/src/allmydata/web/checker_results.py @@ -82,7 +82,7 @@ class LiteralCheckerResults(rend.Page, ResultsBase): data = {"storage-index": "", "results": {"healthy": True}, } - return simplejson.dumps(data, indent=1) + return simplejson.dumps(data, indent=1) + "\n" class CheckerResults(rend.Page, ResultsBase): docFactory = getxmlfile("checker-results.xhtml") @@ -98,7 +98,7 @@ class CheckerResults(rend.Page, ResultsBase): def json(self, ctx): inevow.IRequest(ctx).setHeader("content-type", "text/plain") data = self._json_check_results(self.r) - return simplejson.dumps(data, indent=1) + return simplejson.dumps(data, indent=1) + "\n" def render_storage_index(self, ctx, data): return self.r.get_storage_index_string() @@ -133,7 +133,7 @@ class CheckAndRepairResults(rend.Page, ResultsBase): def json(self, ctx): inevow.IRequest(ctx).setHeader("content-type", "text/plain") data = self._json_check_and_repair_results(self.r) - return simplejson.dumps(data, indent=1) + return simplejson.dumps(data, indent=1) + "\n" def render_storage_index(self, ctx, data): return self.r.get_storage_index_string() @@ -200,7 +200,7 @@ class DeepCheckResults(rend.Page, ResultsBase): in self.r.get_all_results().items() if not r.is_healthy() ] data["stats"] = self.r.get_stats() - return simplejson.dumps(data, indent=1) + return simplejson.dumps(data, indent=1) + "\n" def render_root_storage_index(self, ctx, data): return self.r.get_root_storage_index_string() @@ -348,7 +348,7 @@ class DeepCheckAndRepairResults(rend.Page, ResultsBase): in self.r.get_all_results().items() if not r.get_pre_repair_results().is_healthy() ] data["stats"] = self.r.get_stats() - return simplejson.dumps(data, indent=1) + return simplejson.dumps(data, indent=1) + "\n" def render_root_storage_index(self, ctx, data): return self.r.get_root_storage_index_string() diff --git a/src/allmydata/web/directory.py b/src/allmydata/web/directory.py index c4624678..e6cd3332 100644 --- a/src/allmydata/web/directory.py +++ b/src/allmydata/web/directory.py @@ -692,7 +692,7 @@ def DirectoryJSONMetadata(ctx, dirnode): contents['rw_uri'] = drw_uri contents['mutable'] = dirnode.is_mutable() data = ("dirnode", contents) - return simplejson.dumps(data, indent=1) + return simplejson.dumps(data, indent=1) + "\n" d.addCallback(_got) d.addCallback(text_plain, ctx) return d diff --git a/src/allmydata/web/filenode.py b/src/allmydata/web/filenode.py index 664b53c1..f2d9ce25 100644 --- a/src/allmydata/web/filenode.py +++ b/src/allmydata/web/filenode.py @@ -398,7 +398,7 @@ def FileJSONMetadata(ctx, filenode): if rw_uri: data[1]['rw_uri'] = rw_uri data[1]['mutable'] = filenode.is_mutable() - return text_plain(simplejson.dumps(data, indent=1), ctx) + return text_plain(simplejson.dumps(data, indent=1) + "\n", ctx) def FileURI(ctx, filenode): return text_plain(filenode.get_uri(), ctx) diff --git a/src/allmydata/web/introweb.py b/src/allmydata/web/introweb.py index 14ef9a51..b2e9fa67 100644 --- a/src/allmydata/web/introweb.py +++ b/src/allmydata/web/introweb.py @@ -36,7 +36,7 @@ class IntroducerRoot(rend.Page): announcement_summary[service_name] += 1 res["announcement_summary"] = announcement_summary - return simplejson.dumps(res, indent=1) + return simplejson.dumps(res, indent=1) + "\n" def data_version(self, ctx, data): return get_package_versions_string() diff --git a/src/allmydata/web/status.py b/src/allmydata/web/status.py index 2c9bafaa..f97ca515 100644 --- a/src/allmydata/web/status.py +++ b/src/allmydata/web/status.py @@ -805,7 +805,7 @@ class Status(rend.Page): "progress": s.get_progress(), }) - return simplejson.dumps(data, indent=1) + return simplejson.dumps(data, indent=1) + "\n" def _get_all_statuses(self, client): return itertools.chain(client.list_all_upload_statuses(), @@ -931,10 +931,10 @@ class HelperStatus(rend.Page): try: h = IClient(ctx).getServiceNamed("helper") except KeyError: - return simplejson.dumps({}) + return simplejson.dumps({}) + "\n" stats = h.get_stats() - return simplejson.dumps(stats, indent=1) + return simplejson.dumps(stats, indent=1) + "\n" def render_active_uploads(self, ctx, data): return data["chk_upload_helper.active_uploads"] @@ -974,7 +974,7 @@ class Statistics(rend.Page): t = get_arg(inevow.IRequest(ctx), "t") if t == "json": inevow.IRequest(ctx).setHeader("content-type", "text/plain") - return simplejson.dumps(stats, indent=1) + return simplejson.dumps(stats, indent=1) + "\n" # is there a better way to provide 'data' to all rendering methods? self.original = stats return rend.Page.renderHTTP(self, ctx)