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
|
|
@ -18,7 +18,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import base
|
||||
from . import base
|
||||
from sat.core.i18n import _
|
||||
from sat_frontends.jp.constants import Const as C
|
||||
from sat_frontends.jp import common
|
||||
|
|
@ -29,7 +29,7 @@ import json
|
|||
|
||||
__commands__ = ["Forums"]
|
||||
|
||||
FORUMS_TMP_DIR = u"forums"
|
||||
FORUMS_TMP_DIR = "forums"
|
||||
|
||||
|
||||
class Edit(base.CommandBase, common.BaseEdit):
|
||||
|
|
@ -43,7 +43,7 @@ class Edit(base.CommandBase, common.BaseEdit):
|
|||
use_pubsub=True,
|
||||
use_draft=True,
|
||||
use_verbose=True,
|
||||
help=_(u"edit forums"),
|
||||
help=_("edit forums"),
|
||||
)
|
||||
common.BaseEdit.__init__(self, self.host, FORUMS_TMP_DIR)
|
||||
self.need_loop = True
|
||||
|
|
@ -52,17 +52,16 @@ class Edit(base.CommandBase, common.BaseEdit):
|
|||
self.parser.add_argument(
|
||||
"-k",
|
||||
"--key",
|
||||
type=base.unicode_decoder,
|
||||
default=u"",
|
||||
help=_(u"forum key (DEFAULT: default forums)"),
|
||||
default="",
|
||||
help=_("forum key (DEFAULT: default forums)"),
|
||||
)
|
||||
|
||||
def getTmpSuff(self):
|
||||
"""return suffix used for content file"""
|
||||
return u"json"
|
||||
return "json"
|
||||
|
||||
def forumsSetCb(self):
|
||||
self.disp(_(u"forums have been edited"), 1)
|
||||
self.disp(_("forums have been edited"), 1)
|
||||
self.host.quit()
|
||||
|
||||
def publish(self, forums_raw):
|
||||
|
|
@ -75,7 +74,7 @@ class Edit(base.CommandBase, common.BaseEdit):
|
|||
callback=self.forumsSetCb,
|
||||
errback=partial(
|
||||
self.errback,
|
||||
msg=_(u"can't set forums: {}"),
|
||||
msg=_("can't set forums: {}"),
|
||||
exit_code=C.EXIT_BRIDGE_ERRBACK,
|
||||
),
|
||||
)
|
||||
|
|
@ -94,12 +93,12 @@ class Edit(base.CommandBase, common.BaseEdit):
|
|||
|
||||
def forumsGetEb(self, failure_):
|
||||
# FIXME: error handling with bridge is broken, need to be properly fixed
|
||||
if failure_.condition == u"item-not-found":
|
||||
self.forumsGetCb(u"")
|
||||
if failure_.condition == "item-not-found":
|
||||
self.forumsGetCb("")
|
||||
else:
|
||||
self.errback(
|
||||
failure_,
|
||||
msg=_(u"can't get forums structure: {}"),
|
||||
msg=_("can't get forums structure: {}"),
|
||||
exit_code=C.EXIT_BRIDGE_ERRBACK,
|
||||
)
|
||||
|
||||
|
|
@ -125,7 +124,7 @@ class Get(base.CommandBase):
|
|||
extra_outputs=extra_outputs,
|
||||
use_pubsub=True,
|
||||
use_verbose=True,
|
||||
help=_(u"get forums structure"),
|
||||
help=_("get forums structure"),
|
||||
)
|
||||
self.need_loop = True
|
||||
|
||||
|
|
@ -133,9 +132,8 @@ class Get(base.CommandBase):
|
|||
self.parser.add_argument(
|
||||
"-k",
|
||||
"--key",
|
||||
type=base.unicode_decoder,
|
||||
default=u"",
|
||||
help=_(u"forum key (DEFAULT: default forums)"),
|
||||
default="",
|
||||
help=_("forum key (DEFAULT: default forums)"),
|
||||
)
|
||||
|
||||
def default_output(self, forums, level=0):
|
||||
|
|
@ -143,33 +141,33 @@ class Get(base.CommandBase):
|
|||
keys = list(forum.keys())
|
||||
keys.sort()
|
||||
try:
|
||||
keys.remove(u"title")
|
||||
keys.remove("title")
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
keys.insert(0, u"title")
|
||||
keys.insert(0, "title")
|
||||
try:
|
||||
keys.remove(u"sub-forums")
|
||||
keys.remove("sub-forums")
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
keys.append(u"sub-forums")
|
||||
keys.append("sub-forums")
|
||||
|
||||
for key in keys:
|
||||
value = forum[key]
|
||||
if key == "sub-forums":
|
||||
self.default_output(value, level + 1)
|
||||
else:
|
||||
if self.host.verbosity < 1 and key != u"title":
|
||||
if self.host.verbosity < 1 and key != "title":
|
||||
continue
|
||||
head_color = C.A_LEVEL_COLORS[level % len(C.A_LEVEL_COLORS)]
|
||||
self.disp(
|
||||
A.color(level * 4 * u" ", head_color, key, A.RESET, u": ", value)
|
||||
A.color(level * 4 * " ", head_color, key, A.RESET, ": ", value)
|
||||
)
|
||||
|
||||
def forumsGetCb(self, forums_raw):
|
||||
if not forums_raw:
|
||||
self.disp(_(u"no schema found"), 1)
|
||||
self.disp(_("no schema found"), 1)
|
||||
self.host.quit(1)
|
||||
forums = json.loads(forums_raw)
|
||||
self.output(forums)
|
||||
|
|
@ -184,7 +182,7 @@ class Get(base.CommandBase):
|
|||
callback=self.forumsGetCb,
|
||||
errback=partial(
|
||||
self.errback,
|
||||
msg=_(u"can't get forums: {}"),
|
||||
msg=_("can't get forums: {}"),
|
||||
exit_code=C.EXIT_BRIDGE_ERRBACK,
|
||||
),
|
||||
)
|
||||
|
|
@ -195,5 +193,5 @@ class Forums(base.CommandBase):
|
|||
|
||||
def __init__(self, host):
|
||||
super(Forums, self).__init__(
|
||||
host, "forums", use_profile=False, help=_(u"Forums structure edition")
|
||||
host, "forums", use_profile=False, help=_("Forums structure edition")
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue