Mercurial > libervia-backend
comparison src/twisted/plugins/sat_plugin.py @ 1122:9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 24 Aug 2014 18:44:17 +0200 |
parents | src/sat.tac@a836b6da2c5c |
children | adea30ca0b51 |
comparison
equal
deleted
inserted
replaced
1121:64ff259d3cbb | 1122:9ae01ccf89c1 |
---|---|
1 #!/usr/bin/python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # SAT: a jabber client | |
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) | |
6 | |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 from twisted.internet import defer | |
21 if defer.Deferred.debug: | |
22 # if we are in debug mode, we want to use ipdb instead of pdb | |
23 try: | |
24 import ipdb | |
25 import pdb | |
26 pdb.set_trace = ipdb.set_trace | |
27 pdb.post_mortem = ipdb.post_mortem | |
28 except ImportError: | |
29 pass | |
30 | |
31 from zope.interface import implements | |
32 from twisted.python import usage | |
33 from twisted.plugin import IPlugin | |
34 from twisted.application.service import IServiceMaker | |
35 | |
36 # XXX: We need to configure logs before any log method is used, so here is the best place. | |
37 from sat.core.constants import Const as C | |
38 from sat.core import log_config | |
39 log_config.satConfigure(C.LOG_BACKEND_TWISTED) | |
40 | |
41 # XXX: SAT must be imported after log configuration, because it write stuff to logs | |
42 from sat.core.sat_main import SAT | |
43 from sat.core.i18n import _ | |
44 | |
45 | |
46 class Options(usage.Options): | |
47 optParameters = [] | |
48 | |
49 | |
50 class SatMaker(object): | |
51 implements(IServiceMaker, IPlugin) | |
52 | |
53 tapname = C.APP_NAME_FILE | |
54 description = _(u"%s XMPP client backend") % C.APP_NAME_FULL | |
55 options = Options | |
56 | |
57 def makeService(self, options): | |
58 return SAT() | |
59 | |
60 | |
61 serviceMaker = SatMaker() |