Author: humbedooh
Date: Sun Mar 22 09:42:58 2015
New Revision: 1668347

URL: http://svn.apache.org/r1668347
Log:
catch errors, spit 'em out.
also add 206 as a valid response code (partial content)

Modified:
    steve/trunk/pytest/www/cgi-bin/lib/response.py
    steve/trunk/pytest/www/cgi-bin/rest_admin.py

Modified: steve/trunk/pytest/www/cgi-bin/lib/response.py
URL: 
http://svn.apache.org/viewvc/steve/trunk/pytest/www/cgi-bin/lib/response.py?rev=1668347&r1=1668346&r2=1668347&view=diff
==============================================================================
--- steve/trunk/pytest/www/cgi-bin/lib/response.py (original)
+++ steve/trunk/pytest/www/cgi-bin/lib/response.py Sun Mar 22 09:42:58 2015
@@ -4,6 +4,7 @@ import json
 responseCodes = {
     200: 'Okay',
     201: 'Created',
+    206: 'Partial content',
     304: 'Not Modified',
     400: 'Bad Request',
     403: 'Access denied',

Modified: steve/trunk/pytest/www/cgi-bin/rest_admin.py
URL: 
http://svn.apache.org/viewvc/steve/trunk/pytest/www/cgi-bin/rest_admin.py?rev=1668347&r1=1668346&r2=1668347&view=diff
==============================================================================
--- steve/trunk/pytest/www/cgi-bin/rest_admin.py (original)
+++ steve/trunk/pytest/www/cgi-bin/rest_admin.py Sun Mar 22 09:42:58 2015
@@ -64,6 +64,7 @@ else:
         # List all existing/previous elections?
         if action == "list":
             output = []
+            errors = []
             path = os.path.join(homedir, "issues")
             elections = [ f for f in listdir(path) if 
os.path.isdir(os.path.join(path,f))]
             for election in elections:
@@ -77,9 +78,12 @@ else:
                         basedata['id'] = election
                         if karma >= 5 or ('owner' in basedata and 
basedata['owner'] == whoami):
                             output.append(basedata)
-                except:
-                    pass
-            response.respond(200, { 'elections': output})
+                except Exception as err:
+                    errors.append("Could not parse election '%s': %s" % 
(election, err))
+            if len(errors) > 0:
+                response.respond(206, { 'elections': output, 'errors': errors})
+            else:
+                response.respond(200, { 'elections': output})
         # Set up new election?
         elif action == "setup":
             if karma >= 5: # karma of 5 required to set up an election base


Reply via email to