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
|
||||
import cmd
|
||||
import sys
|
||||
from sat.core.i18n import _
|
||||
|
|
@ -31,7 +31,7 @@ import subprocess
|
|||
|
||||
__commands__ = ["Shell"]
|
||||
INTRO = _(
|
||||
u"""Welcome to {app_name} shell, the Salut à Toi shell !
|
||||
"""Welcome to {app_name} shell, the Salut à Toi shell !
|
||||
|
||||
This enrironment helps you using several {app_name} commands with similar parameters.
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ Enter "help" or "?" to know what to do
|
|||
class Shell(base.CommandBase, cmd.Cmd):
|
||||
def __init__(self, host):
|
||||
base.CommandBase.__init__(
|
||||
self, host, "shell", help=_(u"launch jp in shell (REPL) mode")
|
||||
self, host, "shell", help=_("launch jp in shell (REPL) mode")
|
||||
)
|
||||
cmd.Cmd.__init__(self)
|
||||
|
||||
|
|
@ -54,22 +54,22 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
|
||||
def update_path(self):
|
||||
self._cur_parser = self.host.parser
|
||||
self.help = u""
|
||||
self.help = ""
|
||||
for idx, path_elt in enumerate(self.path):
|
||||
try:
|
||||
self._cur_parser = arg_tools.get_cmd_choices(path_elt, self._cur_parser)
|
||||
except exceptions.NotFound:
|
||||
self.disp(_(u"bad command path"), error=True)
|
||||
self.disp(_("bad command path"), error=True)
|
||||
self.path = self.path[:idx]
|
||||
break
|
||||
else:
|
||||
self.help = self._cur_parser
|
||||
|
||||
self.prompt = A.color(C.A_PROMPT_PATH, u"/".join(self.path)) + A.color(
|
||||
C.A_PROMPT_SUF, u"> "
|
||||
self.prompt = A.color(C.A_PROMPT_PATH, "/".join(self.path)) + A.color(
|
||||
C.A_PROMPT_SUF, "> "
|
||||
)
|
||||
try:
|
||||
self.actions = arg_tools.get_cmd_choices(parser=self._cur_parser).keys()
|
||||
self.actions = list(arg_tools.get_cmd_choices(parser=self._cur_parser).keys())
|
||||
except exceptions.NotFound:
|
||||
self.actions = []
|
||||
|
||||
|
|
@ -100,9 +100,9 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
# Situation should be better when we'll move away from python-dbus
|
||||
if self.verbose:
|
||||
self.disp(
|
||||
_(u"COMMAND {external}=> {args}").format(
|
||||
external=_(u"(external) ") if external else u"",
|
||||
args=u" ".join(self.format_args(args)),
|
||||
_("COMMAND {external}=> {args}").format(
|
||||
external=_("(external) ") if external else "",
|
||||
args=" ".join(self.format_args(args)),
|
||||
)
|
||||
)
|
||||
if not external:
|
||||
|
|
@ -124,7 +124,7 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
self.disp(
|
||||
A.color(
|
||||
C.A_FAILURE,
|
||||
u"command failed with an error code of {err_no}".format(
|
||||
"command failed with an error code of {err_no}".format(
|
||||
err_no=ret_code
|
||||
),
|
||||
),
|
||||
|
|
@ -145,12 +145,12 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
def do_help(self, args):
|
||||
"""show help message"""
|
||||
if not args:
|
||||
self.disp(A.color(C.A_HEADER, _(u"Shell commands:")), no_lf=True)
|
||||
self.disp(A.color(C.A_HEADER, _("Shell commands:")), no_lf=True)
|
||||
super(Shell, self).do_help(args)
|
||||
if not args:
|
||||
self.disp(A.color(C.A_HEADER, _(u"Action commands:")))
|
||||
self.disp(A.color(C.A_HEADER, _("Action commands:")))
|
||||
help_list = self._cur_parser.format_help().split("\n\n")
|
||||
print("\n\n".join(help_list[1 if self.path else 2 :]))
|
||||
print(("\n\n".join(help_list[1 if self.path else 2 :])))
|
||||
|
||||
def do_debug(self, args):
|
||||
"""launch internal debugger"""
|
||||
|
|
@ -166,8 +166,8 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
if args:
|
||||
self.verbose = C.bool(args[0])
|
||||
self.disp(
|
||||
_(u"verbose mode is {status}").format(
|
||||
status=_(u"ENABLED") if self.verbose else _(u"DISABLED")
|
||||
_("verbose mode is {status}").format(
|
||||
status=_("ENABLED") if self.verbose else _("DISABLED")
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
# so we need to add it in arguments to use current user profile
|
||||
if self.verbose:
|
||||
self.disp(
|
||||
_(u"arg profile={profile} (logged profile)").format(
|
||||
_("arg profile={profile} (logged profile)").format(
|
||||
profile=self.profile
|
||||
)
|
||||
)
|
||||
|
|
@ -233,25 +233,25 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
args = self.parse_args(args)
|
||||
if not args:
|
||||
if not self.use:
|
||||
self.disp(_(u"no argument in USE"))
|
||||
self.disp(_("no argument in USE"))
|
||||
else:
|
||||
self.disp(_(u"arguments in USE:"))
|
||||
for arg, value in self.use.iteritems():
|
||||
self.disp(_("arguments in USE:"))
|
||||
for arg, value in self.use.items():
|
||||
self.disp(
|
||||
_(
|
||||
A.color(
|
||||
C.A_SUBHEADER,
|
||||
arg,
|
||||
A.RESET,
|
||||
u" = ",
|
||||
" = ",
|
||||
arg_tools.escape(value),
|
||||
)
|
||||
)
|
||||
)
|
||||
elif len(args) != 2:
|
||||
self.disp(u"bad syntax, please use:\nuse [arg] [value]", error=True)
|
||||
self.disp("bad syntax, please use:\nuse [arg] [value]", error=True)
|
||||
else:
|
||||
self.use[args[0]] = u" ".join(args[1:])
|
||||
self.use[args[0]] = " ".join(args[1:])
|
||||
if self.verbose:
|
||||
self.disp(
|
||||
"set {name} = {value}".format(
|
||||
|
|
@ -271,25 +271,25 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
except KeyError:
|
||||
self.disp(
|
||||
A.color(
|
||||
C.A_FAILURE, _(u"argument {name} not found").format(name=arg)
|
||||
C.A_FAILURE, _("argument {name} not found").format(name=arg)
|
||||
),
|
||||
error=True,
|
||||
)
|
||||
else:
|
||||
if self.verbose:
|
||||
self.disp(_(u"argument {name} removed").format(name=arg))
|
||||
self.disp(_("argument {name} removed").format(name=arg))
|
||||
|
||||
def do_whoami(self, args):
|
||||
u"""print profile currently used"""
|
||||
"""print profile currently used"""
|
||||
self.disp(self.profile)
|
||||
|
||||
def do_quit(self, args):
|
||||
u"""quit the shell"""
|
||||
self.disp(_(u"good bye!"))
|
||||
"""quit the shell"""
|
||||
self.disp(_("good bye!"))
|
||||
self.host.quit()
|
||||
|
||||
def do_exit(self, args):
|
||||
u"""alias for quit"""
|
||||
"""alias for quit"""
|
||||
self.do_quit(args)
|
||||
|
||||
def start(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue