You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by se...@apache.org on 2015/10/11 01:31:49 UTC

svn commit: r1707931 - /comdev/reporter.apache.org/trunk/site/jiraversions.py

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")