Commits

anatoly techtonik committed 3471621

Run without Sentry client (fixes issue #4)

  • Participants
  • Parent commits 5396f8c

Comments (0)

Files changed (1)

 
 from openid.server import server as OpenIDServer
 
-# Raven for error reporting
-import raven
+# Client for reporting to Sentry exception tracking service
+try:
+    import raven
+except ImportError:
+    raven = None
 
 # local imports
 import store, config, versionpredicate, verify_filetype, rpc
         self.handler = handler
         self.config = handler.config
         self.wfile = handler.wfile
-        self.sentry_client = raven.Client(self.config.sentry_dsn)
         self.env = env
         self.nav_current = None
         self.privkey = None
                     '[PyPI] %(line)s', False, flood_level=10)
                 root.addHandler(hdlr)
 
+        self.sentry_client = None
+        if raven and self.config.sentry_dsn:
+            self.sentry_client = raven.Client(self.config.sentry_dsn)
+        else:
+            logging.info('Raven client for Sentry is disabled')
+
     def run(self):
         ''' Run the request, handling all uncaught errors and finishing off
             cleanly.
                 exc, value, tb = sys.exc_info()
 
                 # attempt to send all the exceptions to Raven
+                success = False
                 try:
-                    self.sentry_client.captureException()
+                    if self.sentry_client:
+                        self.sentry_client.captureException()
+                        success = True
                 except Exception:
+                    pass
+                if not success:
                     # sentry broke so just email the exception like old times
                     if ('connection limit exceeded for non-superusers'
                             not in str(value)):