silence warnings while importing twisted
authorEdouard Tisserant
Thu, 22 Sep 2011 16:59:59 +0200
changeset 612 f44651506a88
parent 611 b665a9001451
child 613 be0ceea3b6dd
silence warnings while importing twisted
Beremiz_service.py
--- a/Beremiz_service.py	Thu Sep 08 20:25:44 2011 +0200
+++ b/Beremiz_service.py	Thu Sep 22 16:59:59 2011 +0200
@@ -487,20 +487,23 @@
         self.daemon.shutdown(True)
 
 if enabletwisted:
-    try:
-        from threading import Thread, currentThread
-        if havewx:
-            from twisted.internet import wxreactor
-            wxreactor.install()
-        from twisted.internet import reactor, task
-        from twisted.python import log, util
-        from nevow import rend, appserver, inevow, tags, loaders, athena
-        from nevow.page import renderer
-        
-        havetwisted = True
-    except:
-        print "Twisted unavailable !"
-        havetwisted = False
+    import warnings
+    with warnings.catch_warnings():
+        warnings.simplefilter("ignore")
+        try:
+            from threading import Thread, currentThread
+            if havewx:
+                from twisted.internet import wxreactor
+                wxreactor.install()
+            from twisted.internet import reactor, task
+            from twisted.python import log, util
+            from nevow import rend, appserver, inevow, tags, loaders, athena
+            from nevow.page import renderer
+            
+            havetwisted = True
+        except:
+            print "Twisted unavailable !"
+            havetwisted = False
 
 if havetwisted: