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
This commit is contained in:
parent
d21a6a660f
commit
fbfe96c505
1 changed files with 6336 additions and 6398 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# SAT plugin for managing xep-0249
|
||||
|
|
@ -27,7 +27,7 @@ from sat.tools import xml_tools
|
|||
from twisted.words.xish import domish
|
||||
from twisted.words.protocols.jabber import jid
|
||||
|
||||
from zope.interface import implements
|
||||
from zope.interface import implementer
|
||||
|
||||
from wokkel import disco, iwokkel
|
||||
|
||||
|
|
@ -122,9 +122,9 @@ class XEP_0249(object):
|
|||
message["to"] = guest.full()
|
||||
x_elt = message.addElement((NS_X_CONFERENCE, "x"))
|
||||
x_elt["jid"] = room.userhost()
|
||||
for key, value in options.iteritems():
|
||||
for key, value in options.items():
|
||||
if key not in ("password", "reason", "thread"):
|
||||
log.warning(u"Ignoring invalid invite option: {}".format(key))
|
||||
log.warning("Ignoring invalid invite option: {}".format(key))
|
||||
continue
|
||||
x_elt[key] = value
|
||||
# there is not body in this message, so we can use directly send()
|
||||
|
|
@ -137,7 +137,7 @@ class XEP_0249(object):
|
|||
"""
|
||||
client = self.host.getClient(profile_key)
|
||||
log.info(
|
||||
_(u"Invitation accepted for room %(room)s [%(profile)s]")
|
||||
_("Invitation accepted for room %(room)s [%(profile)s]")
|
||||
% {"room": room_jid.userhost(), "profile": client.profile}
|
||||
)
|
||||
d = self.host.plugins["XEP-0045"].join(client, room_jid, client.jid.user, {})
|
||||
|
|
@ -150,13 +150,13 @@ class XEP_0249(object):
|
|||
return True
|
||||
|
||||
try:
|
||||
room_jid_s = x_elt[u"jid"]
|
||||
room_jid_s = x_elt["jid"]
|
||||
except KeyError:
|
||||
log.warning(_(u"invalid invitation received: {xml}").format(
|
||||
log.warning(_("invalid invitation received: {xml}").format(
|
||||
xml=message_elt.toXml()))
|
||||
return False
|
||||
log.info(
|
||||
_(u"Invitation received for room %(room)s [%(profile)s]")
|
||||
_("Invitation received for room %(room)s [%(profile)s]")
|
||||
% {"room": room_jid_s, "profile": client.profile}
|
||||
)
|
||||
from_jid_s = message_elt["from"]
|
||||
|
|
@ -167,7 +167,7 @@ class XEP_0249(object):
|
|||
pass
|
||||
else:
|
||||
log.info(
|
||||
_(u"Invitation silently discarded because user is already in the room.")
|
||||
_("Invitation silently discarded because user is already in the room.")
|
||||
)
|
||||
return
|
||||
|
||||
|
|
@ -179,15 +179,15 @@ class XEP_0249(object):
|
|||
self._accept(room_jid, client.profile)
|
||||
elif autojoin == "never":
|
||||
msg = D_(
|
||||
u"An invitation from %(user)s to join the room %(room)s has been "
|
||||
u"declined according to your personal settings."
|
||||
"An invitation from %(user)s to join the room %(room)s has been "
|
||||
"declined according to your personal settings."
|
||||
) % {"user": from_jid_s, "room": room_jid_s}
|
||||
title = D_("MUC invitation")
|
||||
xml_tools.quickNote(self.host, client, msg, title, C.XMLUI_DATA_LVL_INFO)
|
||||
else: # leave the default value here
|
||||
confirm_msg = D_(
|
||||
u"You have been invited by %(user)s to join the room %(room)s. "
|
||||
u"Do you accept?"
|
||||
"You have been invited by %(user)s to join the room %(room)s. "
|
||||
"Do you accept?"
|
||||
) % {"user": from_jid_s, "room": room_jid_s}
|
||||
confirm_title = D_("MUC invitation")
|
||||
d = xml_tools.deferConfirm(
|
||||
|
|
@ -213,8 +213,8 @@ class XEP_0249(object):
|
|||
contact_jid = jid.JID(contact_jid_s)
|
||||
except (RuntimeError, jid.InvalidFormat, AttributeError):
|
||||
feedback = _(
|
||||
u"You must provide a valid JID to invite, like in '/invite "
|
||||
u"contact@{host}'"
|
||||
"You must provide a valid JID to invite, like in '/invite "
|
||||
"contact@{host}'"
|
||||
).format(host=my_host)
|
||||
self.host.plugins[C.TEXT_CMDS].feedBack(client, feedback, mess_data)
|
||||
return False
|
||||
|
|
@ -224,8 +224,8 @@ class XEP_0249(object):
|
|||
return False
|
||||
|
||||
|
||||
@implementer(iwokkel.IDisco)
|
||||
class XEP_0249_handler(XMPPHandler):
|
||||
implements(iwokkel.IDisco)
|
||||
|
||||
def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
|
||||
return [disco.DiscoFeature(NS_X_CONFERENCE)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue