community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1728882 - /comdev/reporter.apache.org/trunk/site/getjson.py
Date Sat, 06 Feb 2016 21:01:14 GMT
Author: sebb
Date: Sat Feb  6 21:01:13 2016
New Revision: 1728882

URL: http://svn.apache.org/viewvc?rev=1728882&view=rev
Log:
Output using consistent \r\n EOLs

Modified:
    comdev/reporter.apache.org/trunk/site/getjson.py

Modified: comdev/reporter.apache.org/trunk/site/getjson.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/getjson.py?rev=1728882&r1=1728881&r2=1728882&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/getjson.py (original)
+++ comdev/reporter.apache.org/trunk/site/getjson.py Sat Feb  6 21:01:13 2016
@@ -362,9 +362,12 @@ if re.match(r"^[-a-zA-Z0-9_.]+$", user):
         'keys': keys,
         'health': health
     }
-    dump = json.dumps(output, indent=1)
-    print ("Content-Type: application/json\r\nContent-Length: %u\r\n\r\n" % (len(dump)+1))
-    print(dump)
+
+    # AFAICT dumps always uses \n for EOL
+    # Use write rather than print so we don't get any trailing EOL added
+    dump = json.dumps(output, indent=1).replace('\n', '\r\n')
+    sys.stdout.write("Content-Type: application/json\r\nContent-Length: %u\r\n\r\n" % (len(dump)))
+    sys.stdout.write(dump)
 else:
-    print ("Content-Type: text/html\r\n\r\n")
-    print("Unknown or invalid user id presented")
+    sys.stdout.write("Content-Type: text/html\r\n\r\n")
+    sys.stdout.write("Unknown or invalid user id presented")



Mime
View raw message