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:
Goffi 2019-08-13 19:08:41 +02:00
commit fbfe96c505

View file

@ -26,9 +26,9 @@ from sat.tools.common import date_utils
import json
__outputs__ = ["Simple", "Json"]
SIMPLE = u"simple"
JSON = u"json"
JSON_RAW = u"json_raw"
SIMPLE = "simple"
JSON = "json"
JSON_RAW = "json_raw"
class Simple(object):
@ -45,25 +45,25 @@ class Simple(object):
host.register_output(C.OUTPUT_COMPLEX, SIMPLE, self.simple_print)
def simple_print(self, data):
self.host.disp(unicode(data))
self.host.disp(str(data))
def list(self, data):
self.host.disp(u"\n".join(data))
self.host.disp("\n".join(data))
def dict(self, data, indent=0, header_color=C.A_HEADER):
options = self.host.parse_output_options()
self.host.check_output_options({u"no-header"}, options)
show_header = not u"no-header" in options
for k, v in data.iteritems():
self.host.check_output_options({"no-header"}, options)
show_header = not "no-header" in options
for k, v in data.items():
if show_header:
header = A.color(header_color, k) + u": "
header = A.color(header_color, k) + ": "
else:
header = u""
header = ""
self.host.disp(
(
u"{indent}{header}{value}".format(
indent=indent * u" ", header=header, value=v
"{indent}{header}{value}".format(
indent=indent * " ", header=header, value=v
)
)
)
@ -71,11 +71,11 @@ class Simple(object):
def list_dict(self, data):
for idx, datum in enumerate(data):
if idx:
self.host.disp(u"\n")
self.host.disp("\n")
self.dict(datum)
def dict_dict(self, data):
for key, sub_dict in data.iteritems():
for key, sub_dict in data.items():
self.host.disp(A.color(C.A_HEADER, key))
self.dict(sub_dict, indent=4, header_color=C.A_SUBHEADER)
@ -84,7 +84,7 @@ class Simple(object):
for mess_data in data:
(uid, timestamp, from_jid, to_jid, message, subject, mess_type,
extra) = mess_data
time_str = date_utils.date_fmt(timestamp, u"auto_day",
time_str = date_utils.date_fmt(timestamp, "auto_day",
tz_info=date_utils.TZ_LOCAL)
from_jid = jid.JID(from_jid)
if mess_type == C.MESS_TYPE_GROUPCHAT:
@ -96,11 +96,11 @@ class Simple(object):
nick_color = A.BOLD + A.FG_BLUE
else:
nick_color = A.BOLD + A.FG_YELLOW
message = message.values()[0] if message else u""
message = list(message.values())[0] if message else ""
self.host.disp(A.color(
A.FG_CYAN, u'['+time_str+u'] ',
nick_color, nick, A.RESET, A.BOLD, u'> ',
A.FG_CYAN, '['+time_str+'] ',
nick_color, nick, A.RESET, A.BOLD, '> ',
A.RESET, message))