refactoring: rename libervia.frontends.jp to libervia.cli
This commit is contained in:
parent
4ab9bd7bc8
commit
fd16770c19
43 changed files with 139 additions and 138 deletions
|
|
@ -73,7 +73,7 @@ class Launcher:
|
|||
pid = int(pid_file.read_text())
|
||||
except Exception as e:
|
||||
print(f"Can't read PID file at {pid_file}: {e}")
|
||||
# we use the same exit code as DATA_ERROR in jp
|
||||
# we use the same exit code as DATA_ERROR in CLI frontend
|
||||
sys.exit(17)
|
||||
print(f"Terminating {self.APP_NAME}…")
|
||||
os.kill(pid, signal.SIGTERM)
|
||||
|
|
@ -114,7 +114,7 @@ class Launcher:
|
|||
pid = int(pid_file.read_text())
|
||||
except Exception as e:
|
||||
print(f"Can't read PID file at {pid_file}: {e}")
|
||||
# we use the same exit code as DATA_ERROR in jp
|
||||
# we use the same exit code as DATA_ERROR in CLI frontend
|
||||
sys.exit(17)
|
||||
# we check if there is a process
|
||||
# inspired by https://stackoverflow.com/a/568285 and https://stackoverflow.com/a/6940314
|
||||
|
|
|
|||
|
|
@ -86,9 +86,9 @@ namespace: DokuWiki namespace to import (default: root namespace "/")
|
|||
media_repo: URL to the new remote media repository (default: none)
|
||||
limit: maximal number of posts to import (default: 100)
|
||||
|
||||
Example of usage (with jp frontend):
|
||||
Example of usage (with CLI frontend):
|
||||
|
||||
jp import dokuwiki -p dave --pwd xxxxxx --connect
|
||||
li import dokuwiki -p dave --pwd xxxxxx --connect
|
||||
http://127.0.1.1 -o user souliane -o passwd qwertz
|
||||
-o namespace public:2015:10
|
||||
-o media_repo http://media.diekulturvermittlung.at
|
||||
|
|
|
|||
|
|
@ -589,7 +589,7 @@ class Renderer(object):
|
|||
@return (tuple[unicode, unicode]): theme and absolute path to theme's root dir
|
||||
@raise NotFound: requested site has not been found
|
||||
"""
|
||||
# FIXME: check use in jp, and include site
|
||||
# FIXME: check use in CLI frontend, and include site
|
||||
site, theme, __ = self.env.loader.parse_template(template)
|
||||
if site is None:
|
||||
# absolute template
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -42,7 +42,7 @@ def get_cmd_choices(cmd=None, parser=None):
|
|||
def get_use_args(host, args, use, verbose=False, parser=None):
|
||||
"""format args for argparse parser with values prefilled
|
||||
|
||||
@param host(JP): jp instance
|
||||
@param host(LiberviaCli): LiberviaCli instance
|
||||
@param args(list(str)): arguments to use
|
||||
@param use(dict[str, str]): arguments to fill if found in parser
|
||||
@param verbose(bool): if True a message will be displayed when argument is used or not
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -45,9 +45,9 @@ from libervia.backend.tools.common import utils
|
|||
from libervia.backend.tools.common import data_format
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
from libervia.backend.core import exceptions
|
||||
import libervia.frontends.jp
|
||||
from libervia.frontends.jp.loops import QuitException, get_jp_loop
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
import libervia.cli
|
||||
from libervia.cli.loops import QuitException, get_libervia_cli_loop
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.frontends.bridge.bridge_frontend import BridgeException
|
||||
from libervia.frontends.tools import misc
|
||||
import xml.etree.ElementTree as ET # FIXME: used temporarily to manage XMLUI
|
||||
|
|
@ -57,7 +57,7 @@ from collections import OrderedDict
|
|||
# we get bridge name from conf and initialise the right class accordingly
|
||||
main_config = config.parse_main_conf()
|
||||
bridge_name = config.config_get(main_config, '', 'bridge', 'dbus')
|
||||
JPLoop = get_jp_loop(bridge_name)
|
||||
LiberviaCLILoop = get_libervia_cli_loop(bridge_name)
|
||||
|
||||
|
||||
try:
|
||||
|
|
@ -519,11 +519,11 @@ class LiberviaCli:
|
|||
self.quit(C.EXIT_BAD_ARG)
|
||||
|
||||
def import_plugins(self):
|
||||
"""Automaticaly import commands and outputs in jp
|
||||
"""Automaticaly import commands and outputs in CLI frontend
|
||||
|
||||
looks from modules names cmd_*.py in jp path and import them
|
||||
looks from modules names cmd_*.py in CLI frontend path and import them
|
||||
"""
|
||||
path = os.path.dirname(libervia.frontends.jp.__file__)
|
||||
path = os.path.dirname(libervia.cli.__file__)
|
||||
# XXX: outputs must be imported before commands as they are used for arguments
|
||||
for type_, pattern in ((C.PLUGIN_OUTPUT, 'output_*.py'),
|
||||
(C.PLUGIN_CMD, 'cmd_*.py')):
|
||||
|
|
@ -531,7 +531,7 @@ class LiberviaCli:
|
|||
os.path.splitext(module)[0]
|
||||
for module in map(os.path.basename, iglob(os.path.join(path, pattern))))
|
||||
for module_name in modules:
|
||||
module_path = "libervia.frontends.jp." + module_name
|
||||
module_path = "libervia.cli." + module_name
|
||||
try:
|
||||
module = import_module(module_path)
|
||||
self.import_plugin_module(module, type_)
|
||||
|
|
@ -549,7 +549,7 @@ class LiberviaCli:
|
|||
|
||||
|
||||
def import_plugin_module(self, module, type_):
|
||||
"""add commands or outpus from a module to jp
|
||||
"""add commands or outpus from a module to CLI frontend
|
||||
|
||||
@param module: module containing commands or outputs
|
||||
@param type_(str): one of C_PLUGIN_*
|
||||
|
|
@ -727,7 +727,7 @@ class LiberviaCli:
|
|||
return
|
||||
|
||||
def _run(self, args=None, namespace=None):
|
||||
self.loop = JPLoop()
|
||||
self.loop = LiberviaCLILoop()
|
||||
self.loop.run(self, args, namespace)
|
||||
|
||||
@classmethod
|
||||
|
|
@ -931,8 +931,8 @@ class LiberviaCli:
|
|||
if not self.args.connect:
|
||||
self.disp(_(
|
||||
"Session for [{profile}] is not started, please start it "
|
||||
"before using jp, or use either --start-session or --connect "
|
||||
"option"
|
||||
"before using libervia-cli, or use either --start-session or "
|
||||
"--connect option"
|
||||
.format(profile=self.profile)
|
||||
), error=True)
|
||||
self.quit(1)
|
||||
|
|
@ -954,7 +954,7 @@ class LiberviaCli:
|
|||
if not await self.bridge.is_connected(self.profile):
|
||||
log.error(
|
||||
_("Profile [{profile}] is not connected, please connect it "
|
||||
"before using jp, or use --connect option")
|
||||
"before using libervia-cli, or use --connect option")
|
||||
.format(profile=self.profile)
|
||||
)
|
||||
self.quit(1)
|
||||
|
|
@ -994,7 +994,7 @@ class CommandBase:
|
|||
):
|
||||
"""Initialise CommandBase
|
||||
|
||||
@param host: Jp instance
|
||||
@param host: LiberviaCli instance
|
||||
@param name: name of the new command
|
||||
@param use_profile: if True, add profile selection/connection commands
|
||||
@param use_output: if not False, add --output option
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
"""This module permits to manage XMPP accounts using in-band registration (XEP-0077)"""
|
||||
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.frontends.bridge.bridge_frontend import BridgeException
|
||||
from libervia.backend.core.log import getLogger
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp import base
|
||||
from libervia.cli import base
|
||||
from libervia.frontends.tools import jid
|
||||
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.frontends.jp import xmlui_manager
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.cli import xmlui_manager
|
||||
|
||||
__commands__ = ["AdHoc"]
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.tools.common import data_format
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
|
||||
__commands__ = ["Application"]
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -23,7 +23,7 @@ import os.path
|
|||
import asyncio
|
||||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.tools import config
|
||||
from libervia.backend.tools.common import data_format
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -22,8 +22,8 @@ import json
|
|||
import os
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.tools.common import data_format
|
||||
from libervia.frontends.jp import common
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli import common
|
||||
from libervia.cli.constants import Const as C
|
||||
from . import base
|
||||
|
||||
__commands__ = ["Blocking"]
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -36,8 +36,8 @@ from libervia.backend.tools import config
|
|||
from libervia.backend.tools.common import uri
|
||||
from libervia.backend.tools.common import data_format
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
from libervia.frontends.jp import common
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli import common
|
||||
from libervia.cli.constants import Const as C
|
||||
|
||||
from . import base, cmd_pubsub
|
||||
|
||||
|
|
@ -600,7 +600,8 @@ class Edit(base.CommandBase, BlogPublishCommon, common.BaseEdit):
|
|||
mb_data["publish"] = False
|
||||
|
||||
# then we create the file and write metadata there, as JSON dict
|
||||
# XXX: if we port jp one day on Windows, O_BINARY may need to be added here
|
||||
# XXX: if we port libervia-cli one day on Windows, O_BINARY may need to be
|
||||
# added here
|
||||
with os.fdopen(
|
||||
os.open(meta_file_path, os.O_RDWR | os.O_CREAT | os.O_TRUNC, 0o600), "w+b"
|
||||
) as f:
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
|
||||
__commands__ = ["Bookmarks"]
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
import json
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -17,11 +17,11 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from libervia.frontends.jp import base
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli import base
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.tools.common import data_format
|
||||
from libervia.frontends.jp import xmlui_manager
|
||||
from libervia.cli import xmlui_manager
|
||||
|
||||
__commands__ = ["Encryption"]
|
||||
|
||||
|
|
@ -30,9 +30,9 @@ from libervia.backend.tools.common import data_format
|
|||
from libervia.backend.tools.common import date_utils
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
from libervia.frontends.jp import common
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli import common
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
|
||||
from . import base
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -26,8 +26,8 @@ import os.path
|
|||
import tarfile
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.tools.common import data_format
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.frontends.jp import common
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.cli import common
|
||||
from libervia.frontends.tools import jid
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
from libervia.backend.tools.common import utils
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.frontends.jp import common
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.cli import common
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
import codecs
|
||||
import json
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.tools.common import data_format
|
||||
|
||||
__commands__ = ["Identity"]
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -22,8 +22,8 @@ from pprint import pformat
|
|||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.tools.common import data_format, date_utils
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
from libervia.frontends.jp import common
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli import common
|
||||
from libervia.cli.constants import Const as C
|
||||
|
||||
from . import base
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -26,7 +26,7 @@ import asyncio
|
|||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
|
||||
__commands__ = ["Input"]
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
from libervia.backend.tools.common import data_format
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -22,8 +22,8 @@ import json
|
|||
import os
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.tools.common import data_format
|
||||
from libervia.frontends.jp import common
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli import common
|
||||
from libervia.cli.constants import Const as C
|
||||
from . import base
|
||||
|
||||
__commands__ = ["List"]
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -22,9 +22,9 @@ import os.path
|
|||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.tools.common import data_format
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.frontends.jp import xmlui_manager
|
||||
from libervia.frontends.jp import common
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.cli import xmlui_manager
|
||||
from libervia.cli import common
|
||||
|
||||
__commands__ = ["MergeRequest"]
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -26,8 +26,8 @@ from libervia.backend.core.i18n import _
|
|||
from libervia.backend.tools.common import data_format
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
from libervia.backend.tools.utils import clean_ustr
|
||||
from libervia.frontends.jp import base
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli import base
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.frontends.tools import jid
|
||||
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
# Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org)
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
|
||||
__commands__ = ["Ping"]
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -25,9 +25,9 @@ import sys
|
|||
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.tools.common import data_format
|
||||
from libervia.frontends.jp import base
|
||||
from libervia.frontends.jp import xmlui_manager
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli import base
|
||||
from libervia.cli import xmlui_manager
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.frontends.tools import jid
|
||||
|
||||
__commands__ = ["Pipe"]
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -20,10 +20,10 @@
|
|||
"""This module permits to manage profiles. It can list, create, delete
|
||||
and retrieve information about a profile."""
|
||||
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.core.log import getLogger
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp import base
|
||||
from libervia.cli import base
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -28,10 +28,10 @@ import json
|
|||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.frontends.jp import common
|
||||
from libervia.frontends.jp import arg_tools
|
||||
from libervia.frontends.jp import xml_tools
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.cli import common
|
||||
from libervia.cli import arg_tools
|
||||
from libervia.cli import xml_tools
|
||||
from functools import partial
|
||||
from libervia.backend.tools.common import data_format
|
||||
from libervia.backend.tools.common import uri
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
# Copyright (C) 2003-2016 Adrien Cossa (souliane@mailoo.org)
|
||||
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
from . import base
|
||||
from collections import OrderedDict
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.frontends.tools import jid
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -25,8 +25,8 @@ import subprocess
|
|||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.frontends.jp import arg_tools
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.cli import arg_tools
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
|
||||
__commands__ = ["Shell"]
|
||||
|
|
@ -45,7 +45,7 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
def __init__(self, host):
|
||||
base.CommandBase.__init__(
|
||||
self, host, "shell",
|
||||
help=_("launch jp in shell (REPL) mode")
|
||||
help=_("launch libervia-cli in shell (REPL) mode")
|
||||
)
|
||||
cmd.Cmd.__init__(self)
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
|
||||
@param args[list[string]]: arguments of the command
|
||||
must not include program name
|
||||
@param external(bool): True if it's an external command (i.e. not jp)
|
||||
@param external(bool): True if it's an external command (i.e. not libervia-cli)
|
||||
@return (int): exit code (0 success, any other int failure)
|
||||
"""
|
||||
# FIXME: we have to use subprocess
|
||||
|
|
@ -190,7 +190,7 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
self.update_path()
|
||||
|
||||
def do_version(self, args):
|
||||
"""show current SàT/jp version"""
|
||||
"""show current backend/CLI version"""
|
||||
self.run_cmd(['--version'])
|
||||
|
||||
def do_shell(self, args):
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
from . import base
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.tools.common import uri
|
||||
|
||||
__commands__ = ["Uri"]
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -26,7 +26,7 @@ import asyncio
|
|||
import shlex
|
||||
import re
|
||||
from pathlib import Path
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.backend.tools.common import regex
|
||||
|
|
@ -189,7 +189,7 @@ class BaseEdit(object):
|
|||
):
|
||||
"""Run editor to edit content and metadata
|
||||
|
||||
@param editor_args_opt(unicode): option in [jp] section in configuration for
|
||||
@param editor_args_opt(unicode): option in [cli] section in configuration for
|
||||
specific args
|
||||
@param content_file_path(str): path to the content file
|
||||
@param content_file_obj(file): opened file instance
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# jp: a SAT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -20,7 +20,7 @@ import sys
|
|||
import asyncio
|
||||
import logging as log
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
|
||||
log.basicConfig(level=log.WARNING,
|
||||
format='[%(name)s] %(message)s')
|
||||
|
|
@ -35,20 +35,20 @@ class QuitException(BaseException):
|
|||
"""
|
||||
|
||||
|
||||
def get_jp_loop(bridge_name):
|
||||
def get_libervia_cli_loop(bridge_name):
|
||||
if 'dbus' in bridge_name:
|
||||
import signal
|
||||
import threading
|
||||
from gi.repository import GLib
|
||||
|
||||
class JPLoop:
|
||||
class LiberviaCLILoop:
|
||||
|
||||
def run(self, jp, args, namespace):
|
||||
def run(self, libervia_cli, args, namespace):
|
||||
signal.signal(signal.SIGINT, self._on_sigint)
|
||||
self._glib_loop = GLib.MainLoop()
|
||||
threading.Thread(target=self._glib_loop.run).start()
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(jp.main(args=args, namespace=namespace))
|
||||
loop.run_until_complete(libervia_cli.main(args=args, namespace=namespace))
|
||||
loop.run_forever()
|
||||
|
||||
def quit(self, exit_code):
|
||||
|
|
@ -82,31 +82,31 @@ def get_jp_loop(bridge_name):
|
|||
asyncioreactor.install()
|
||||
from twisted.internet import reactor, defer
|
||||
|
||||
class JPLoop:
|
||||
class LiberviaCLILoop:
|
||||
|
||||
def __init__(self):
|
||||
# exit code must be set when using quit, so if it's not set
|
||||
# something got wrong and we must report it
|
||||
self._exit_code = C.EXIT_INTERNAL_ERROR
|
||||
|
||||
def run(self, jp, *args):
|
||||
self.jp = jp
|
||||
def run(self, libervia_cli, *args):
|
||||
self.libervia_cli = libervia_cli
|
||||
signal.signal(signal.SIGINT, self._on_sigint)
|
||||
defer.ensureDeferred(self._start(jp, *args))
|
||||
defer.ensureDeferred(self._start(libervia_cli, *args))
|
||||
try:
|
||||
reactor.run(installSignalHandlers=False)
|
||||
except SystemExit as e:
|
||||
self._exit_code = e.code
|
||||
sys.exit(self._exit_code)
|
||||
|
||||
async def _start(self, jp, *args):
|
||||
fut = asyncio.ensure_future(jp.main(*args))
|
||||
async def _start(self, libervia_cli, *args):
|
||||
fut = asyncio.ensure_future(libervia_cli.main(*args))
|
||||
try:
|
||||
await defer.Deferred.fromFuture(fut)
|
||||
except BaseException:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
jp.quit(1)
|
||||
libervia_cli.quit(1)
|
||||
|
||||
def quit(self, exit_code):
|
||||
self._exit_code = exit_code
|
||||
|
|
@ -142,4 +142,4 @@ def get_jp_loop(bridge_name):
|
|||
# from sat.core import sat_main
|
||||
# sat = sat_main.SAT()
|
||||
|
||||
return JPLoop
|
||||
return LiberviaCLILoop
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
"""Standard outputs"""
|
||||
|
||||
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.frontends.tools import jid
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
from libervia.backend.tools.common import date_utils
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
"""Standard outputs"""
|
||||
|
||||
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.core import log
|
||||
from libervia.backend.tools.common import template
|
||||
|
|
@ -37,9 +37,9 @@ OPTIONS = {"template", "browser", "inline-css"}
|
|||
class Template(object):
|
||||
"""outputs data using SàT templates"""
|
||||
|
||||
def __init__(self, jp):
|
||||
self.host = jp
|
||||
jp.register_output(C.OUTPUT_COMPLEX, TEMPLATE, self.render)
|
||||
def __init__(self, libervia_cli):
|
||||
self.host = libervia_cli
|
||||
libervia_cli.register_output(C.OUTPUT_COMPLEX, TEMPLATE, self.render)
|
||||
|
||||
def _front_url_tmp_dir(self, ctx, relative_url, tmp_dir):
|
||||
"""Get front URL for temporary directory"""
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
"""Standard outputs"""
|
||||
|
||||
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.core.i18n import _
|
||||
from lxml import etree
|
||||
from libervia.backend.core.log import getLogger
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
"""Standard outputs"""
|
||||
|
||||
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.frontends.jp import xmlui_manager
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.cli import xmlui_manager
|
||||
from libervia.backend.core.log import getLogger
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# jp: a SàT command line tool
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
|
||||
def etree_parse(cmd, raw_xml, reraise=False):
|
||||
"""import lxml and parse raw XML
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# JP: a SàT frontend
|
||||
# Libervia CLI
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
from functools import partial
|
||||
from libervia.backend.core.log import getLogger
|
||||
from libervia.frontends.tools import xmlui as xmlui_base
|
||||
from libervia.frontends.jp.constants import Const as C
|
||||
from libervia.cli.constants import Const as C
|
||||
from libervia.backend.tools.common.ansi import ANSI as A
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.tools.common import data_format
|
||||
|
|
@ -202,7 +202,7 @@ class LabelWidget(xmlui_base.LabelWidget, ValueWidget):
|
|||
async def show(self, end="\n", ansi=""):
|
||||
"""show label
|
||||
|
||||
@param end(str): same as for [JP.disp]
|
||||
@param end(str): same as for [LiberviaCli.disp]
|
||||
@param ansi(unicode): ansi escape code to print before label
|
||||
"""
|
||||
self.disp(A.color(ansi, self.value), end=end)
|
||||
|
|
@ -274,8 +274,8 @@ class XHTMLBoxWidget(xmlui_base.XHTMLBoxWidget, StringWidget):
|
|||
|
||||
async def show(self):
|
||||
# FIXME: we use bridge in a blocking way as permitted by python-dbus
|
||||
# this only for now to make it simpler, it must be refactored
|
||||
# to use async when jp will be fully async (expected for 0.8)
|
||||
# this only for now to make it simpler, it must be refactored to use async
|
||||
# when libervia-cli will be fully async (expected for 0.8)
|
||||
self.value = await self.host.bridge.syntax_convert(
|
||||
self.value, C.SYNTAX_XHTML, "markdown", False, self.host.profile
|
||||
)
|
||||
6
setup.py
6
setup.py
|
|
@ -132,9 +132,9 @@ setup(
|
|||
"sat = libervia.backend.core.launcher:Launcher.run",
|
||||
|
||||
# CLI + aliases
|
||||
"libervia-cli = libervia.frontends.jp.base:LiberviaCli.run",
|
||||
"li = libervia.frontends.jp.base:LiberviaCli.run",
|
||||
"jp = libervia.frontends.jp.base:LiberviaCli.run",
|
||||
"libervia-cli = libervia.cli.base:LiberviaCli.run",
|
||||
"li = libervia.cli.base:LiberviaCli.run",
|
||||
"jp = libervia.cli.base:LiberviaCli.run",
|
||||
|
||||
# TUI + alias
|
||||
"libervia-tui = libervia.frontends.primitivus.base:PrimitivusApp.run",
|
||||
|
|
|
|||
Loading…
Reference in a new issue