diff twisted/plugins/sat_plugin.py @ 3053:8b36e5c3f28f

misc: don't import memory in launch script: launch script was importing a method from memory (fixLocalDir), but memory is importing twisted.internet.reactor which can result to a ReactorAlreadyInstalledError. This patch fixes it by moving fixLocalDir to tools/config. The launch script is now using /usr/bin/env.
author Goffi <goffi@goffi.org>
date Tue, 08 Oct 2019 12:10:26 +0200
parents fee60f17ebac
children 2180b0f5c1cd
line wrap: on
line diff
--- a/twisted/plugins/sat_plugin.py	Mon Oct 07 17:29:28 2019 +0200
+++ b/twisted/plugins/sat_plugin.py	Tue Oct 08 12:10:26 2019 +0200
@@ -17,16 +17,6 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-from twisted.internet import defer
-if defer.Deferred.debug:
-    # if we are in debug mode, we want to use ipdb instead of pdb
-    try:
-        import ipdb
-        import pdb
-        pdb.set_trace = ipdb.set_trace
-        pdb.post_mortem = ipdb.post_mortem
-    except ImportError:
-        pass
 
 from zope.interface import implementer
 from twisted.python import usage
@@ -56,9 +46,22 @@
     description = _("%s XMPP client backend") % C.APP_NAME_FULL
     options = Options
 
+    def setDebugger(self):
+        from twisted.internet import defer
+        if defer.Deferred.debug:
+            # if we are in debug mode, we want to use ipdb instead of pdb
+            try:
+                import ipdb
+                import pdb
+                pdb.set_trace = ipdb.set_trace
+                pdb.post_mortem = ipdb.post_mortem
+            except ImportError:
+                pass
+
     def makeService(self, options):
         from twisted.internet import gireactor
         gireactor.install()
+        self.setDebugger()
         # XXX: SAT must be imported after log configuration, because it write stuff to logs
         initialise(options.parent)
         from sat.core.sat_main import SAT