community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1707931 - /comdev/reporter.apache.org/trunk/site/jiraversions.py
Date Sat, 10 Oct 2015 23:31:49 GMT
Author: sebb
Date: Sat Oct 10 23:31:49 2015
New Revision: 1707931

URL: http://svn.apache.org/viewvc?rev=1707931&view=rev
Log:
Better handling of IO Errors

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

Modified: comdev/reporter.apache.org/trunk/site/jiraversions.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/jiraversions.py?rev=1707931&r1=1707930&r2=1707931&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/jiraversions.py (original)
+++ comdev/reporter.apache.org/trunk/site/jiraversions.py Sat Oct 10 23:31:49 2015
@@ -61,12 +61,16 @@ if (isMember(user) or project in groups)
                 rdata[entry['name']] = date
     except Exception as err:
         pass
-    with open("/var/www/reporter.apache.org/data/releases/%s.json" % project, "w") as f:
-        json.dump(rdata, f, indent=1, sort_keys=True)
-        f.close()
-          
-    print("Content-Type: application/json\r\n\r\n")
-    print(json.dumps({'status': 'Fetched', 'versions': rdata}, indent=1))
-    
+    try:
+        with open("/var/www/reporter.apache.org/data/releases/%s.json" % project, "w") as
f:
+            json.dump(rdata, f, indent=1, sort_keys=True)
+            f.close()
+    except Exception as e:
+        # Use json.dumps to ensure that quotes are handled correctly
+        print("Content-Type: application/json\r\n\r\n%s\r\n" % json.dumps({"status": str(e)}))
+    else:
+        print("Content-Type: application/json\r\n\r\n")
+        print(json.dumps({'status': 'Fetched', 'versions': rdata}, indent=1))
+
 else:
     print("Content-Type: application/json\r\n\r\n{\"status\": \"Data missing\"}\r\n")



Mime
View raw message