Commits

Marc-Alexandre Chan committed 6e93c39

Fixed handling for certain HTTP errors; fixed var typo in scheduler _retry_event

Comments (0)

Files changed (2)

minibot/errors.py

 
 # REDDIT
 from praw.errors import *
-from urllib2 import HTTPError
+from urllib2 import HTTPError, URLError
 
 # SQL
-from sqlalchemy.exc import SQLAlchemyError, DBAPIError
+from sqlalchemy.exc import SQLAlchemyError, DBAPIError

minibot/eventscheduler.py

 from minibot.util import classname, log_exc_info
 from minibot.errors import ResourceError, AttachedEventError, InvalidUserPass,\
     LoginRequired, NotLoggedIn, RateLimitExceeded, EventNotFoundError,\
-    HTTPError, MinibotError, SchedulerStoppedError
+    HTTPError, URLError, MinibotError, SchedulerStoppedError
 
 from praw import Reddit
 
             self._retry_event(evtime, priority, status, event)
             return True
 
-        elif isinstance(exc, HTTPError) or\
+        elif isinstance(exc, HTTPError) or isinstance(exc, URLError) or\
                 (isinstance(exc, ValueError) and "No JSON object" in exc):
             # oh, is Reddit having some issues?
             if not hasattr(event, 'delay') or event.delay<self.DELAY_HTTPERROR:
                 u"time=%s, priority=%d, status=%s, event=%s",
                 classname(self),
                 time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(r_time)),
-                r_priority, self.STATUS_STRING[r_status], unicode(event))
+                r_priority, self.STATUS_STRING[status], unicode(event))
         else:
             self.logger.debug(
                 u"%s: Queued retry: "
                 u"time=%s, priority=%d, status=%s, event=%s",
                 classname(self),
                 time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(r_time)),
-                r_priority, self.STATUS_STRING[r_status], unicode(event))
+                r_priority, self.STATUS_STRING[status], unicode(event))
         event.delay = None
 
     def prepare_event(self, event):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.