Mercurial > libervia-backend
comparison sat/core/patches.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 | 00d905e1b0ef |
children | 691283719bb2 |
comparison
equal
deleted
inserted
replaced
3027:ff5bcb12ae60 | 3028:ab2696e34d29 |
---|---|
82 self._onElementHooks = [] | 82 self._onElementHooks = [] |
83 self._sendHooks = [] | 83 self._sendHooks = [] |
84 | 84 |
85 def addHook(self, hook_type, callback): | 85 def addHook(self, hook_type, callback): |
86 """Add a send or receive hook""" | 86 """Add a send or receive hook""" |
87 conflict_msg = (u"Hook conflict: can't add {hook_type} hook {callback}" | 87 conflict_msg = ("Hook conflict: can't add {hook_type} hook {callback}" |
88 .format(hook_type=hook_type, callback=callback)) | 88 .format(hook_type=hook_type, callback=callback)) |
89 if hook_type == C.STREAM_HOOK_RECEIVE: | 89 if hook_type == C.STREAM_HOOK_RECEIVE: |
90 if callback not in self._onElementHooks: | 90 if callback not in self._onElementHooks: |
91 self._onElementHooks.append(callback) | 91 self._onElementHooks.append(callback) |
92 else: | 92 else: |
95 if callback not in self._sendHooks: | 95 if callback not in self._sendHooks: |
96 self._sendHooks.append(callback) | 96 self._sendHooks.append(callback) |
97 else: | 97 else: |
98 log.warning(conflict_msg) | 98 log.warning(conflict_msg) |
99 else: | 99 else: |
100 raise ValueError(u"Invalid hook type: {hook_type}" | 100 raise ValueError("Invalid hook type: {hook_type}" |
101 .format(hook_type=hook_type)) | 101 .format(hook_type=hook_type)) |
102 | 102 |
103 def onElement(self, element): | 103 def onElement(self, element): |
104 for hook in self._onElementHooks: | 104 for hook in self._onElementHooks: |
105 hook(element) | 105 hook(element) |
159 jid.__internJIDs[jidstring] = j | 159 jid.__internJIDs[jidstring] = j |
160 return copy.copy(j) | 160 return copy.copy(j) |
161 | 161 |
162 | 162 |
163 def apply(): | 163 def apply(): |
164 # certificate validation | 164 # FIXME: certificate validation is now implemented in Twisted trunk, to be removed |
165 xmlstream.TLSInitiatingInitializer = TLSInitiatingInitializer | 165 # # certificate validation |
166 client.XMPPClient = XMPPClient | 166 # xmlstream.TLSInitiatingInitializer = TLSInitiatingInitializer |
167 # client.XMPPClient = XMPPClient | |
167 # XmlStream triggers | 168 # XmlStream triggers |
168 xmlstream.XmlStreamFactory.protocol = XmlStream | 169 xmlstream.XmlStreamFactory.protocol = XmlStream |
169 # jid fix | 170 # jid fix |
170 jid.internJID = internJID | 171 jid.internJID = internJID |