jp: jp asyncio port:
/!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\ This patch implements the port of jp to asyncio, so it is now correctly using the bridge asynchronously, and it can be used with bridges like `pb`. This also simplify the code, notably for things which were previously implemented with many callbacks (like pagination with RSM). During the process, some behaviours have been modified/fixed, in jp and backends, check diff for details.
This commit is contained in:
parent
5cee4fbab7
commit
76aadbb3fb
1 changed files with 3299 additions and 3300 deletions
|
|
@ -18,16 +18,16 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from . import base
|
||||
import cmd
|
||||
import sys
|
||||
import shlex
|
||||
import subprocess
|
||||
from . import base
|
||||
from sat.core.i18n import _
|
||||
from sat.core import exceptions
|
||||
from sat_frontends.jp.constants import Const as C
|
||||
from sat_frontends.jp import arg_tools
|
||||
from sat.tools.common.ansi import ANSI as A
|
||||
import shlex
|
||||
import subprocess
|
||||
|
||||
__commands__ = ["Shell"]
|
||||
INTRO = _(
|
||||
|
|
@ -44,7 +44,8 @@ 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=_("launch jp in shell (REPL) mode")
|
||||
self, host, "shell",
|
||||
help=_("launch jp in shell (REPL) mode")
|
||||
)
|
||||
cmd.Cmd.__init__(self)
|
||||
|
||||
|
|
@ -152,13 +153,15 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
help_list = self._cur_parser.format_help().split("\n\n")
|
||||
print(("\n\n".join(help_list[1 if self.path else 2 :])))
|
||||
|
||||
def do_debug(self, args):
|
||||
"""launch internal debugger"""
|
||||
try:
|
||||
import ipdb as pdb
|
||||
except ImportError:
|
||||
import pdb
|
||||
pdb.set_trace()
|
||||
# FIXME: debug crashes on exit and is not that useful,
|
||||
# keeping it until refactoring, may be removed entirely then
|
||||
# def do_debug(self, args):
|
||||
# """launch internal debugger"""
|
||||
# try:
|
||||
# import ipdb as pdb
|
||||
# except ImportError:
|
||||
# import pdb
|
||||
# pdb.set_trace()
|
||||
|
||||
def do_verbose(self, args):
|
||||
"""show verbose mode, or (de)activate it"""
|
||||
|
|
@ -188,10 +191,7 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
|
||||
def do_version(self, args):
|
||||
"""show current SàT/jp version"""
|
||||
try:
|
||||
self.host.run(["--version"])
|
||||
except SystemExit:
|
||||
pass
|
||||
self.run_cmd(['--version'])
|
||||
|
||||
def do_shell(self, args):
|
||||
"""launch an external command (you can use ![command] too)"""
|
||||
|
|
@ -292,7 +292,9 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
"""alias for quit"""
|
||||
self.do_quit(args)
|
||||
|
||||
def start(self):
|
||||
async def start(self):
|
||||
# FIXME: "shell" is currently kept synchronous as it works well as it
|
||||
# and it will be refactored soon.
|
||||
default_profile = self.host.bridge.profileNameGet(C.PROF_KEY_DEFAULT)
|
||||
self._not_default_profile = self.profile != default_profile
|
||||
self.path = []
|
||||
|
|
@ -300,4 +302,4 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
self.use = {}
|
||||
self.verbose = False
|
||||
self.update_path()
|
||||
self.cmdloop(INTRO.encode("utf-8"))
|
||||
self.cmdloop(INTRO)
|
||||
|
|
|
|||
Loading…
Reference in a new issue