Mercurial > libervia-backend
annotate src/twisted/plugins/sat_plugin.py @ 2131:628c1c95f442
plugin XEP-0334: fixed and improved message processing hints:
- wrong elements were used in this plugging, it could not work properly
- use constants for hints
- add addHint method so other plugins can add a hint easily
- hints can be added by frontends in mess_data['extra']['hints'] (serialized dict) or by other plugins using addHint
- if history is skipped on message reception, mess_data['extra']['history']['skipped'] is set
- introduced PLUGIN_INFO['usage'] for usage information for developers
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 05 Feb 2017 14:55:19 +0100 |
parents | 2daf7b4c6756 |
children | 8b37a62336c3 |
rev | line source |
---|---|
1934
2daf7b4c6756
use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents:
1766
diff
changeset
|
1 #!/usr/bin/env python2 |
0 | 2 # -*- coding: utf-8 -*- |
3 | |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
4 # SAT: a jabber client |
1766 | 5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org) |
0 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
10 # (at your option) any later version. |
0 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
15 # GNU Affero General Public License for more details. |
0 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
0 | 19 |
1014
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
20 from twisted.internet import defer |
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
21 if defer.Deferred.debug: |
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
22 # if we are in debug mode, we want to use ipdb instead of pdb |
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
23 try: |
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
24 import ipdb |
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
25 import pdb |
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
26 pdb.set_trace = ipdb.set_trace |
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
27 pdb.post_mortem = ipdb.post_mortem |
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
28 except ImportError: |
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
29 pass |
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
30 |
1122
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
31 from zope.interface import implements |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
32 from twisted.python import usage |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
33 from twisted.plugin import IPlugin |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
34 from twisted.application.service import IServiceMaker |
0 | 35 |
994
652c01ca69b1
core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents:
991
diff
changeset
|
36 # XXX: We need to configure logs before any log method is used, so here is the best place. |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
994
diff
changeset
|
37 from sat.core.constants import Const as C |
1130 | 38 from sat.core.i18n import _ |
39 | |
991
05e02f8b7eb4
core: logging refactoring, first step:
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
40 |
1130 | 41 def initialise(options): |
42 """Method to initialise global modules""" | |
43 from twisted.internet import glib2reactor | |
44 glib2reactor.install() | |
45 # XXX: We need to configure logs before any log method is used, so here is the best place. | |
46 from sat.core import log_config | |
47 log_config.satConfigure(C.LOG_BACKEND_TWISTED, C, backend_data=options) | |
1122
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
48 |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
49 |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
50 class Options(usage.Options): |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
51 optParameters = [] |
101 | 52 |
994
652c01ca69b1
core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents:
991
diff
changeset
|
53 |
1122
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
54 class SatMaker(object): |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
55 implements(IServiceMaker, IPlugin) |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
56 |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
57 tapname = C.APP_NAME_FILE |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
58 description = _(u"%s XMPP client backend") % C.APP_NAME_FULL |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
59 options = Options |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
60 |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
61 def makeService(self, options): |
1130 | 62 # XXX: SAT must be imported after log configuration, because it write stuff to logs |
63 initialise(options.parent) | |
64 from sat.core.sat_main import SAT | |
1122
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
65 return SAT() |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
66 |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
67 |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
68 serviceMaker = SatMaker() |