Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0163.py @ 3028:ab2696e34d29
Python 3 port:
/!\ this is a huge commit
/!\ starting from this commit, SàT is needs Python 3.6+
/!\ SàT maybe be instable or some feature may not work anymore, this will improve with time
This patch port backend, bridge and frontends to Python 3.
Roughly this has been done this way:
- 2to3 tools has been applied (with python 3.7)
- all references to python2 have been replaced with python3 (notably shebangs)
- fixed files not handled by 2to3 (notably the shell script)
- several manual fixes
- fixed issues reported by Python 3 that where not handled in Python 2
- replaced "async" with "async_" when needed (it's a reserved word from Python 3.7)
- replaced zope's "implements" with @implementer decorator
- temporary hack to handle data pickled in database, as str or bytes may be returned,
to be checked later
- fixed hash comparison for password
- removed some code which is not needed anymore with Python 3
- deactivated some code which needs to be checked (notably certificate validation)
- tested with jp, fixed reported issues until some basic commands worked
- ported Primitivus (after porting dependencies like urwid satext)
- more manual fixes
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 13 Aug 2019 19:08:41 +0200 |
parents | 0b7ce5daee9b |
children | 9d0df638c8b4 |
comparison
equal
deleted
inserted
replaced
3027:ff5bcb12ae60 | 3028:ab2696e34d29 |
---|---|
1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python3 |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 | 3 |
4 # SAT plugin for Personal Eventing Protocol (xep-0163) | 4 # SAT plugin for Personal Eventing Protocol (xep-0163) |
5 # Copyright (C) 2009-2019 Jérôme Poisson (goffi@goffi.org) | 5 # Copyright (C) 2009-2019 Jérôme Poisson (goffi@goffi.org) |
6 | 6 |
54 "PEPSend", | 54 "PEPSend", |
55 ".plugin", | 55 ".plugin", |
56 in_sign="sa{ss}s", | 56 in_sign="sa{ss}s", |
57 out_sign="", | 57 out_sign="", |
58 method=self.PEPSend, | 58 method=self.PEPSend, |
59 async=True, | 59 async_=True, |
60 ) # args: type(MOOD, TUNE, etc), data, profile_key; | 60 ) # args: type(MOOD, TUNE, etc), data, profile_key; |
61 self.addPEPEvent("MOOD", NS_USER_MOOD, self.userMoodCB, self.sendMood) | 61 self.addPEPEvent("MOOD", NS_USER_MOOD, self.userMoodCB, self.sendMood) |
62 | 62 |
63 def disoInfoTrigger(self, disco_info, profile): | 63 def disoInfoTrigger(self, disco_info, profile): |
64 """Add info from managed PEP | 64 """Add info from managed PEP |
65 | 65 |
66 @param disco_info: list of disco feature as returned by PubSub, | 66 @param disco_info: list of disco feature as returned by PubSub, |
67 will be filled with PEP features | 67 will be filled with PEP features |
68 @param profile: profile we are handling | 68 @param profile: profile we are handling |
69 """ | 69 """ |
70 disco_info.extend(map(disco.DiscoFeature, self.pep_events)) | 70 disco_info.extend(list(map(disco.DiscoFeature, self.pep_events))) |
71 return True | 71 return True |
72 | 72 |
73 def addPEPEvent(self, event_type, node, in_callback, out_callback=None, notify=True): | 73 def addPEPEvent(self, event_type, node, in_callback, out_callback=None, notify=True): |
74 """Add a Personal Eventing Protocol event manager | 74 """Add a Personal Eventing Protocol event manager |
75 | 75 |
126 @param profile_key: profile who send the event | 126 @param profile_key: profile who send the event |
127 """ | 127 """ |
128 profile = self.host.memory.getProfileName(profile_key) | 128 profile = self.host.memory.getProfileName(profile_key) |
129 if not profile: | 129 if not profile: |
130 log.error( | 130 log.error( |
131 _(u"Trying to send personal event with an unknown profile key [%s]") | 131 _("Trying to send personal event with an unknown profile key [%s]") |
132 % profile_key | 132 % profile_key |
133 ) | 133 ) |
134 raise exceptions.ProfileUnknownError | 134 raise exceptions.ProfileUnknownError |
135 if not event_type in self.pep_out_cb.keys(): | 135 if not event_type in list(self.pep_out_cb.keys()): |
136 log.error(_("Trying to send personal event for an unknown type")) | 136 log.error(_("Trying to send personal event for an unknown type")) |
137 raise exceptions.DataError("Type unknown") | 137 raise exceptions.DataError("Type unknown") |
138 return self.pep_out_cb[event_type](data, profile) | 138 return self.pep_out_cb[event_type](data, profile) |
139 | 139 |
140 def userMoodCB(self, itemsEvent, profile): | 140 def userMoodCB(self, itemsEvent, profile): |