comparison twisted/plugins/libervia_backend_plugin.py @ 4081:84f6bee6440d

installation: moved from `setup.py` to `pyproject.toml`: - updated installation to use the now standard `pyproject.toml` instead of legacy `setup.py`. `setup.py` and other legacy files have been deleted. - removed outdated README4PACKAGERS - removed pylintrc which has not been correctly reviewed. Linter conf should go to `pyproject.toml` now. - [hatch](https://hatch.pypa.io) is now used as main building tool. However, thanks to the use of standards, other tools can be used too. - update .hgignore - several dependencies version bump, with code update to adapt to changes.
author Goffi <goffi@goffi.org>
date Tue, 06 Jun 2023 16:45:16 +0200
parents twisted/plugins/sat_plugin.py@15055a00162c
children
comparison
equal deleted inserted replaced
4080:0ea6b34f8f18 4081:84f6bee6440d
1 #!/usr/bin/env python3
2
3 # Libervia: an XMPP client
4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
5
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
15
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19
20 from zope.interface import implementer
21 from twisted.python import usage
22 from twisted.plugin import IPlugin
23 from twisted.application.service import IServiceMaker
24
25 # XXX: We need to configure logs before any log method is used, so here is the best place.
26 from libervia.backend.core.constants import Const as C
27 from libervia.backend.core.i18n import _
28
29 from sat_tmp.wokkel import install as install_wokkel_patches
30
31
32 install_wokkel_patches()
33
34
35 def initialise(options):
36 """Method to initialise global modules"""
37 # XXX: We need to configure logs before any log method is used, so here is the best place.
38 from libervia.backend.core import log_config
39 log_config.libervia_configure(C.LOG_BACKEND_TWISTED, C, backend_data=options)
40
41
42 class Options(usage.Options):
43 optParameters = []
44
45
46 @implementer(IPlugin, IServiceMaker)
47 class LiberviaMaker:
48
49 tapname = C.APP_NAME_FILE
50 description = _("%s XMPP client backend") % C.APP_NAME_FULL
51 options = Options
52
53 def set_debugger(self):
54 from twisted.internet import defer
55 if defer.Deferred.debug:
56 # if we are in debug mode, we want to use ipdb instead of pdb
57 try:
58 import ipdb
59 import pdb
60 pdb.set_trace = ipdb.set_trace
61 pdb.post_mortem = ipdb.post_mortem
62 except ImportError:
63 pass
64
65 def makeService(self, options):
66 from twisted.internet import asyncioreactor
67 asyncioreactor.install()
68 self.set_debugger()
69 # XXX: Libervia must be imported after log configuration,
70 # because it write stuff to logs
71 initialise(options.parent)
72 from libervia.backend.core.main import LiberviaBackend
73 return LiberviaBackend()
74
75
76 serviceMaker = LiberviaMaker()