massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
This commit is contained in:
parent
d50412c7f7
commit
6a6f15707a
32 changed files with 9945 additions and 9945 deletions
|
|
@ -46,7 +46,7 @@ from sat.tools.common import data_format
|
|||
from sat.tools.common.ansi import ANSI as A
|
||||
from sat.core import exceptions
|
||||
import sat_frontends.jp
|
||||
from sat_frontends.jp.loops import QuitException, getJPLoop
|
||||
from sat_frontends.jp.loops import QuitException, get_jp_loop
|
||||
from sat_frontends.jp.constants import Const as C
|
||||
from sat_frontends.bridge.bridge_frontend import BridgeException
|
||||
from sat_frontends.tools import misc
|
||||
|
|
@ -55,9 +55,9 @@ from collections import OrderedDict
|
|||
|
||||
## bridge handling
|
||||
# we get bridge name from conf and initialise the right class accordingly
|
||||
main_config = config.parseMainConf()
|
||||
bridge_name = config.getConfig(main_config, '', 'bridge', 'dbus')
|
||||
JPLoop = getJPLoop(bridge_name)
|
||||
main_config = config.parse_main_conf()
|
||||
bridge_name = config.config_get(main_config, '', 'bridge', 'dbus')
|
||||
JPLoop = get_jp_loop(bridge_name)
|
||||
|
||||
|
||||
try:
|
||||
|
|
@ -118,7 +118,7 @@ class LiberviaCli:
|
|||
|
||||
def get_config(self, name, section=C.CONFIG_SECTION, default=None):
|
||||
"""Retrieve a setting value from sat.conf"""
|
||||
return config.getConfig(self.sat_conf, section, name, default=default)
|
||||
return config.config_get(self.sat_conf, section, name, default=default)
|
||||
|
||||
def guess_background(self):
|
||||
# cf. https://unix.stackexchange.com/a/245568 (thanks!)
|
||||
|
|
@ -204,7 +204,7 @@ class LiberviaCli:
|
|||
C.A_DIRECTORY = A.BOLD + A.FG_MAGENTA
|
||||
C.A_FILE = A.FG_BLACK
|
||||
|
||||
def _bridgeConnected(self):
|
||||
def _bridge_connected(self):
|
||||
self.parser = argparse.ArgumentParser(
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter, description=DESCRIPTION)
|
||||
self._make_parents()
|
||||
|
|
@ -231,7 +231,7 @@ class LiberviaCli:
|
|||
async def set_progress_id(self, progress_id):
|
||||
# because we use async, we need an explicit setter
|
||||
self._progress_id = progress_id
|
||||
await self.replayCache('progress_ids_cache')
|
||||
await self.replay_cache('progress_ids_cache')
|
||||
|
||||
@property
|
||||
def watch_progress(self):
|
||||
|
|
@ -254,7 +254,7 @@ class LiberviaCli:
|
|||
except AttributeError:
|
||||
return 0
|
||||
|
||||
async def replayCache(self, cache_attribute):
|
||||
async def replay_cache(self, cache_attribute):
|
||||
"""Replay cached signals
|
||||
|
||||
@param cache_attribute(str): name of the attribute containing the cache
|
||||
|
|
@ -294,14 +294,14 @@ class LiberviaCli:
|
|||
if inspect.isawaitable(ret):
|
||||
await ret
|
||||
|
||||
def addOnQuitCallback(self, callback, *args, **kwargs):
|
||||
def add_on_quit_callback(self, callback, *args, **kwargs):
|
||||
"""Add a callback which will be called on quit command
|
||||
|
||||
@param callback(callback): method to call
|
||||
"""
|
||||
self._onQuitCallbacks.append((callback, args, kwargs))
|
||||
|
||||
def getOutputChoices(self, output_type):
|
||||
def get_output_choices(self, output_type):
|
||||
"""Return valid output filters for output_type
|
||||
|
||||
@param output_type: True for default,
|
||||
|
|
@ -612,7 +612,7 @@ class LiberviaCli:
|
|||
url = self.get_xmpp_uri_from_http(url)
|
||||
|
||||
try:
|
||||
uri_data = uri.parseXMPPUri(url)
|
||||
uri_data = uri.parse_xmpp_uri(url)
|
||||
except ValueError:
|
||||
self.parser.error(_('invalid XMPP URL: {url}').format(url=url))
|
||||
else:
|
||||
|
|
@ -694,7 +694,7 @@ class LiberviaCli:
|
|||
|
||||
async def main(self, args, namespace):
|
||||
try:
|
||||
await self.bridge.bridgeConnect()
|
||||
await self.bridge.bridge_connect()
|
||||
except Exception as e:
|
||||
if isinstance(e, exceptions.BridgeExceptionNoService):
|
||||
print(
|
||||
|
|
@ -711,9 +711,9 @@ class LiberviaCli:
|
|||
)
|
||||
self.quit(C.EXIT_BRIDGE_ERROR, raise_exc=False)
|
||||
return
|
||||
await self.bridge.getReady()
|
||||
self.version = await self.bridge.getVersion()
|
||||
self._bridgeConnected()
|
||||
await self.bridge.ready_get()
|
||||
self.version = await self.bridge.version_get()
|
||||
self._bridge_connected()
|
||||
self.import_plugins()
|
||||
try:
|
||||
self.args = self.parser.parse_args(args, namespace=None)
|
||||
|
|
@ -756,14 +756,14 @@ class LiberviaCli:
|
|||
res = await self.ainput(f"{message} (y/N)? ")
|
||||
return res in ("y", "Y")
|
||||
|
||||
async def confirmOrQuit(self, message, cancel_message=_("action cancelled by user")):
|
||||
async def confirm_or_quit(self, message, cancel_message=_("action cancelled by user")):
|
||||
"""Request user to confirm action, and quit if he doesn't"""
|
||||
confirmed = await self.confirm(message)
|
||||
if not confirmed:
|
||||
self.disp(cancel_message)
|
||||
self.quit(C.EXIT_USER_CANCELLED)
|
||||
|
||||
def quitFromSignal(self, exit_code=0):
|
||||
def quit_from_signal(self, exit_code=0):
|
||||
r"""Same as self.quit, but from a signal handler
|
||||
|
||||
/!\: return must be used after calling this method !
|
||||
|
|
@ -805,7 +805,7 @@ class LiberviaCli:
|
|||
nodes2jid = {}
|
||||
|
||||
try:
|
||||
contacts = await self.bridge.getContacts(self.profile)
|
||||
contacts = await self.bridge.contacts_get(self.profile)
|
||||
except BridgeException as e:
|
||||
if e.classname == "AttributeError":
|
||||
# we may get an AttributeError if we use a component profile
|
||||
|
|
@ -872,7 +872,7 @@ class LiberviaCli:
|
|||
self.disp('')
|
||||
return pwd
|
||||
|
||||
async def connectOrPrompt(self, method, err_msg=None):
|
||||
async def connect_or_prompt(self, method, err_msg=None):
|
||||
"""Try to connect/start profile session and prompt for password if needed
|
||||
|
||||
@param method(callable): bridge method to either connect or start profile session
|
||||
|
|
@ -907,7 +907,7 @@ class LiberviaCli:
|
|||
"""
|
||||
# FIXME: need better exit codes
|
||||
|
||||
self.profile = await self.bridge.profileNameGet(self.args.profile)
|
||||
self.profile = await self.bridge.profile_name_get(self.args.profile)
|
||||
|
||||
if not self.profile:
|
||||
log.error(
|
||||
|
|
@ -922,12 +922,12 @@ class LiberviaCli:
|
|||
pass
|
||||
else:
|
||||
if start_session:
|
||||
await self.connectOrPrompt(
|
||||
lambda pwd: self.bridge.profileStartSession(pwd, self.profile),
|
||||
await self.connect_or_prompt(
|
||||
lambda pwd: self.bridge.profile_start_session(pwd, self.profile),
|
||||
err_msg="Can't start {profile}'s session: {e}"
|
||||
)
|
||||
return
|
||||
elif not await self.bridge.profileIsSessionStarted(self.profile):
|
||||
elif not await self.bridge.profile_is_session_started(self.profile):
|
||||
if not self.args.connect:
|
||||
self.disp(_(
|
||||
"Session for [{profile}] is not started, please start it "
|
||||
|
|
@ -945,13 +945,13 @@ class LiberviaCli:
|
|||
# creation/deletion)
|
||||
return
|
||||
elif self.args.connect is True: # if connection is asked, we connect the profile
|
||||
await self.connectOrPrompt(
|
||||
await self.connect_or_prompt(
|
||||
lambda pwd: self.bridge.connect(self.profile, pwd, {}),
|
||||
err_msg = 'Can\'t connect profile "{profile!s}": {e}'
|
||||
)
|
||||
return
|
||||
else:
|
||||
if not await self.bridge.isConnected(self.profile):
|
||||
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")
|
||||
|
|
@ -966,14 +966,14 @@ class LiberviaCli:
|
|||
_jid = JID(param_jid)
|
||||
if not _jid.resource:
|
||||
#if the resource is not given, we try to add the main resource
|
||||
main_resource = await self.bridge.getMainResource(param_jid, self.profile)
|
||||
main_resource = await self.bridge.main_resource_get(param_jid, self.profile)
|
||||
if main_resource:
|
||||
return f"{_jid.bare}/{main_resource}"
|
||||
return param_jid
|
||||
|
||||
async def get_profile_jid(self):
|
||||
"""Retrieve current profile bare JID if possible"""
|
||||
full_jid = await self.bridge.asyncGetParamA(
|
||||
full_jid = await self.bridge.param_get_a_async(
|
||||
"JabberID", "Connection", profile_key=self.profile
|
||||
)
|
||||
return full_jid.rsplit("/", 1)[0]
|
||||
|
|
@ -1054,7 +1054,7 @@ class CommandBase:
|
|||
assert use_output in C.OUTPUT_TYPES
|
||||
self._output_type = use_output
|
||||
output_parent = argparse.ArgumentParser(add_help=False)
|
||||
choices = set(self.host.getOutputChoices(use_output))
|
||||
choices = set(self.host.get_output_choices(use_output))
|
||||
choices.update(extra_outputs)
|
||||
if not choices:
|
||||
raise exceptions.InternalError(
|
||||
|
|
@ -1125,14 +1125,14 @@ class CommandBase:
|
|||
async def set_progress_id(self, progress_id):
|
||||
return await self.host.set_progress_id(progress_id)
|
||||
|
||||
async def progressStartedHandler(self, uid, metadata, profile):
|
||||
async def progress_started_handler(self, uid, metadata, profile):
|
||||
if profile != self.profile:
|
||||
return
|
||||
if self.progress_id is None:
|
||||
# the progress started message can be received before the id
|
||||
# so we keep progressStarted signals in cache to replay they
|
||||
# so we keep progress_started signals in cache to replay they
|
||||
# when the progress_id is received
|
||||
cache_data = (self.progressStartedHandler, uid, metadata, profile)
|
||||
cache_data = (self.progress_started_handler, uid, metadata, profile)
|
||||
try:
|
||||
cache = self.host.progress_ids_cache
|
||||
except AttributeError:
|
||||
|
|
@ -1140,14 +1140,14 @@ class CommandBase:
|
|||
cache.append(cache_data)
|
||||
else:
|
||||
if self.host.watch_progress and uid == self.progress_id:
|
||||
await self.onProgressStarted(metadata)
|
||||
await self.on_progress_started(metadata)
|
||||
while True:
|
||||
await asyncio.sleep(PROGRESS_DELAY)
|
||||
cont = await self.progressUpdate()
|
||||
cont = await self.progress_update()
|
||||
if not cont:
|
||||
break
|
||||
|
||||
async def progressFinishedHandler(self, uid, metadata, profile):
|
||||
async def progress_finished_handler(self, uid, metadata, profile):
|
||||
if profile != self.profile:
|
||||
return
|
||||
if uid == self.progress_id:
|
||||
|
|
@ -1155,26 +1155,26 @@ class CommandBase:
|
|||
self.host.pbar.finish()
|
||||
except AttributeError:
|
||||
pass
|
||||
await self.onProgressFinished(metadata)
|
||||
await self.on_progress_finished(metadata)
|
||||
if self.host.quit_on_progress_end:
|
||||
self.host.quitFromSignal()
|
||||
self.host.quit_from_signal()
|
||||
|
||||
async def progressErrorHandler(self, uid, message, profile):
|
||||
async def progress_error_handler(self, uid, message, profile):
|
||||
if profile != self.profile:
|
||||
return
|
||||
if uid == self.progress_id:
|
||||
if self.args.progress:
|
||||
self.disp('') # progress is not finished, so we skip a line
|
||||
if self.host.quit_on_progress_end:
|
||||
await self.onProgressError(message)
|
||||
self.host.quitFromSignal(C.EXIT_ERROR)
|
||||
await self.on_progress_error(message)
|
||||
self.host.quit_from_signal(C.EXIT_ERROR)
|
||||
|
||||
async def progressUpdate(self):
|
||||
async def progress_update(self):
|
||||
"""This method is continualy called to update the progress bar
|
||||
|
||||
@return (bool): False to stop being called
|
||||
"""
|
||||
data = await self.host.bridge.progressGet(self.progress_id, self.profile)
|
||||
data = await self.host.bridge.progress_get(self.progress_id, self.profile)
|
||||
if data:
|
||||
try:
|
||||
size = data['size']
|
||||
|
|
@ -1214,38 +1214,38 @@ class CommandBase:
|
|||
elif self.host.pbar is not None:
|
||||
return False
|
||||
|
||||
await self.onProgressUpdate(data)
|
||||
await self.on_progress_update(data)
|
||||
|
||||
return True
|
||||
|
||||
async def onProgressStarted(self, metadata):
|
||||
async def on_progress_started(self, metadata):
|
||||
"""Called when progress has just started
|
||||
|
||||
can be overidden by a command
|
||||
@param metadata(dict): metadata as sent by bridge.progressStarted
|
||||
@param metadata(dict): metadata as sent by bridge.progress_started
|
||||
"""
|
||||
self.disp(_("Operation started"), 2)
|
||||
|
||||
async def onProgressUpdate(self, metadata):
|
||||
async def on_progress_update(self, metadata):
|
||||
"""Method called on each progress updata
|
||||
|
||||
can be overidden by a command to handle progress metadata
|
||||
@para metadata(dict): metadata as returned by bridge.progressGet
|
||||
@para metadata(dict): metadata as returned by bridge.progress_get
|
||||
"""
|
||||
pass
|
||||
|
||||
async def onProgressFinished(self, metadata):
|
||||
async def on_progress_finished(self, metadata):
|
||||
"""Called when progress has just finished
|
||||
|
||||
can be overidden by a command
|
||||
@param metadata(dict): metadata as sent by bridge.progressFinished
|
||||
@param metadata(dict): metadata as sent by bridge.progress_finished
|
||||
"""
|
||||
self.disp(_("Operation successfully finished"), 2)
|
||||
|
||||
async def onProgressError(self, e):
|
||||
async def on_progress_error(self, e):
|
||||
"""Called when a progress failed
|
||||
|
||||
@param error_msg(unicode): error message as sent by bridge.progressError
|
||||
@param error_msg(unicode): error message as sent by bridge.progress_error
|
||||
"""
|
||||
self.disp(_("Error while doing operation: {e}").format(e=e), error=True)
|
||||
|
||||
|
|
@ -1260,7 +1260,7 @@ class CommandBase:
|
|||
_('trying to use output when use_output has not been set'))
|
||||
return self.host.output(output_type, self.args.output, self.extra_outputs, data)
|
||||
|
||||
def getPubsubExtra(self, extra: Optional[dict] = None) -> str:
|
||||
def get_pubsub_extra(self, extra: Optional[dict] = None) -> str:
|
||||
"""Helper method to compute extra data from pubsub arguments
|
||||
|
||||
@param extra: base extra dict, or None to generate a new one
|
||||
|
|
@ -1328,7 +1328,7 @@ class CommandBase:
|
|||
for cls in subcommands:
|
||||
cls(self)
|
||||
|
||||
def overridePubsubFlags(self, new_flags: Set[str]) -> None:
|
||||
def override_pubsub_flags(self, new_flags: Set[str]) -> None:
|
||||
"""Replace pubsub_flags given in __init__
|
||||
|
||||
useful when a command is extending an other command (e.g. blog command which does
|
||||
|
|
@ -1356,11 +1356,11 @@ class CommandBase:
|
|||
# we need to register the following signal even if we don't display the
|
||||
# progress bar
|
||||
self.host.bridge.register_signal(
|
||||
"progressStarted", self.progressStartedHandler)
|
||||
"progress_started", self.progress_started_handler)
|
||||
self.host.bridge.register_signal(
|
||||
"progressFinished", self.progressFinishedHandler)
|
||||
"progress_finished", self.progress_finished_handler)
|
||||
self.host.bridge.register_signal(
|
||||
"progressError", self.progressErrorHandler)
|
||||
"progress_error", self.progress_error_handler)
|
||||
|
||||
if self.need_connect is not None:
|
||||
await self.host.connect_profile()
|
||||
|
|
@ -1387,7 +1387,7 @@ class CommandAnswering(CommandBase):
|
|||
def __init__(self, *args, **kwargs):
|
||||
super(CommandAnswering, self).__init__(*args, **kwargs)
|
||||
|
||||
async def onActionNew(self, action_data, action_id, security_limit, profile):
|
||||
async def on_action_new(self, action_data, action_id, security_limit, profile):
|
||||
if profile != self.profile:
|
||||
return
|
||||
try:
|
||||
|
|
@ -1398,7 +1398,7 @@ class CommandAnswering(CommandBase):
|
|||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
self.onXMLUI(xml_ui)
|
||||
self.on_xmlui(xml_ui)
|
||||
else:
|
||||
try:
|
||||
callback = self.action_callbacks[action_type]
|
||||
|
|
@ -1407,7 +1407,7 @@ class CommandAnswering(CommandBase):
|
|||
else:
|
||||
await callback(action_data, action_id, security_limit, profile)
|
||||
|
||||
def onXMLUI(self, xml_ui):
|
||||
def on_xmlui(self, xml_ui):
|
||||
"""Display a dialog received from the backend.
|
||||
|
||||
@param xml_ui (unicode): dialog XML representation
|
||||
|
|
@ -1422,7 +1422,7 @@ class CommandAnswering(CommandBase):
|
|||
|
||||
async def start_answering(self):
|
||||
"""Auto reply to confirmation requests"""
|
||||
self.host.bridge.register_signal("actionNew", self.onActionNew)
|
||||
actions = await self.host.bridge.actionsGet(self.profile)
|
||||
self.host.bridge.register_signal("action_new", self.on_action_new)
|
||||
actions = await self.host.bridge.actions_get(self.profile)
|
||||
for action_data, action_id, security_limit in actions:
|
||||
await self.onActionNew(action_data, action_id, security_limit, self.profile)
|
||||
await self.on_action_new(action_data, action_id, security_limit, self.profile)
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class AccountCreate(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
await self.host.bridge.inBandAccountNew(
|
||||
await self.host.bridge.in_band_account_new(
|
||||
self.args.jid,
|
||||
self.args.password,
|
||||
self.args.email,
|
||||
|
|
@ -112,7 +112,7 @@ class AccountCreate(base.CommandBase):
|
|||
|
||||
self.disp(_("creating profile"), 2)
|
||||
try:
|
||||
await self.host.bridge.profileCreate(
|
||||
await self.host.bridge.profile_create(
|
||||
self.args.profile,
|
||||
self.args.password,
|
||||
"",
|
||||
|
|
@ -141,7 +141,7 @@ class AccountCreate(base.CommandBase):
|
|||
|
||||
self.disp(_("profile created"), 1)
|
||||
try:
|
||||
await self.host.bridge.profileStartSession(
|
||||
await self.host.bridge.profile_start_session(
|
||||
self.args.password,
|
||||
self.args.profile,
|
||||
)
|
||||
|
|
@ -150,7 +150,7 @@ class AccountCreate(base.CommandBase):
|
|||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
||||
try:
|
||||
await self.host.bridge.setParam(
|
||||
await self.host.bridge.param_set(
|
||||
"JabberID",
|
||||
self.args.jid,
|
||||
"Connection",
|
||||
|
|
@ -161,7 +161,7 @@ class AccountCreate(base.CommandBase):
|
|||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
||||
try:
|
||||
await self.host.bridge.setParam(
|
||||
await self.host.bridge.param_set(
|
||||
"Password",
|
||||
self.args.password,
|
||||
"Connection",
|
||||
|
|
@ -190,7 +190,7 @@ class AccountModify(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
await self.host.bridge.inBandPasswordChange(
|
||||
await self.host.bridge.in_band_password_change(
|
||||
self.args.password,
|
||||
self.args.profile,
|
||||
)
|
||||
|
|
@ -217,7 +217,7 @@ class AccountDelete(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
jid_str = await self.host.bridge.asyncGetParamA(
|
||||
jid_str = await self.host.bridge.param_get_a_async(
|
||||
"JabberID",
|
||||
"Connection",
|
||||
profile_key=self.profile,
|
||||
|
|
@ -233,10 +233,10 @@ class AccountDelete(base.CommandBase):
|
|||
f"This is the XMPP account of profile {self.profile!r}\n"
|
||||
f"Are you sure that you want to delete this account?"
|
||||
)
|
||||
await self.host.confirmOrQuit(message, _("Account deletion cancelled"))
|
||||
await self.host.confirm_or_quit(message, _("Account deletion cancelled"))
|
||||
|
||||
try:
|
||||
await self.host.bridge.inBandUnregister(jid_.domain, self.args.profile)
|
||||
await self.host.bridge.in_band_unregister(jid_.domain, self.args.profile)
|
||||
except Exception as e:
|
||||
self.disp(f"can't delete XMPP account with jid {jid_!r}: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class Remote(base.CommandBase):
|
|||
if self.args.loop:
|
||||
flags.append(FLAG_LOOP)
|
||||
try:
|
||||
bus_name, methods = await self.host.bridge.adHocDBusAddAuto(
|
||||
bus_name, methods = await self.host.bridge.ad_hoc_dbus_add_auto(
|
||||
name,
|
||||
list(jids),
|
||||
self.args.groups,
|
||||
|
|
@ -145,7 +145,7 @@ class Run(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
xmlui_raw = await self.host.bridge.adHocRun(
|
||||
xmlui_raw = await self.host.bridge.ad_hoc_run(
|
||||
self.args.jid,
|
||||
self.args.node,
|
||||
self.profile,
|
||||
|
|
@ -159,7 +159,7 @@ class Run(base.CommandBase):
|
|||
await xmlui.show(workflow)
|
||||
if not workflow:
|
||||
if xmlui.type == "form":
|
||||
await xmlui.submitForm()
|
||||
await xmlui.submit_form()
|
||||
self.host.quit()
|
||||
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ class List(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
xmlui_raw = await self.host.bridge.adHocList(
|
||||
xmlui_raw = await self.host.bridge.ad_hoc_list(
|
||||
self.args.jid,
|
||||
self.profile,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class List(base.CommandBase):
|
|||
self.args.filters = ['available']
|
||||
|
||||
try:
|
||||
found_apps = await self.host.bridge.applicationsList(self.args.filters)
|
||||
found_apps = await self.host.bridge.applications_list(self.args.filters)
|
||||
except Exception as e:
|
||||
self.disp(f"can't get applications list: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
|
@ -80,7 +80,7 @@ class Start(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
await self.host.bridge.applicationStart(
|
||||
await self.host.bridge.application_start(
|
||||
self.args.name,
|
||||
"",
|
||||
)
|
||||
|
|
@ -117,7 +117,7 @@ class Stop(base.CommandBase):
|
|||
args = [self.args.name, "name"]
|
||||
else:
|
||||
args = [self.args.id, "instance"]
|
||||
await self.host.bridge.applicationStop(
|
||||
await self.host.bridge.application_stop(
|
||||
*args,
|
||||
"",
|
||||
)
|
||||
|
|
@ -161,7 +161,7 @@ class Exposed(base.CommandBase):
|
|||
args = [self.args.name, "name"]
|
||||
else:
|
||||
args = [self.args.id, "instance"]
|
||||
exposed_data_raw = await self.host.bridge.applicationExposedGet(
|
||||
exposed_data_raw = await self.host.bridge.application_exposed_get(
|
||||
*args,
|
||||
"",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ class Get(base.CommandBase):
|
|||
)
|
||||
self.parser.add_argument("jid", nargs='?', default='', help=_("entity"))
|
||||
|
||||
async def showImage(self, path):
|
||||
sat_conf = config.parseMainConf()
|
||||
cmd = config.getConfig(sat_conf, C.CONFIG_SECTION, "image_cmd")
|
||||
async def show_image(self, path):
|
||||
sat_conf = config.parse_main_conf()
|
||||
cmd = config.config_get(sat_conf, C.CONFIG_SECTION, "image_cmd")
|
||||
cmds = [cmd] + DISPLAY_CMD if cmd else DISPLAY_CMD
|
||||
for cmd in cmds:
|
||||
try:
|
||||
|
|
@ -72,7 +72,7 @@ class Get(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
avatar_data_raw = await self.host.bridge.avatarGet(
|
||||
avatar_data_raw = await self.host.bridge.avatar_get(
|
||||
self.args.jid,
|
||||
not self.args.no_cache,
|
||||
self.profile,
|
||||
|
|
@ -91,7 +91,7 @@ class Get(base.CommandBase):
|
|||
|
||||
self.disp(avatar_path)
|
||||
if self.args.show:
|
||||
await self.showImage(avatar_path)
|
||||
await self.show_image(avatar_path)
|
||||
|
||||
self.host.quit()
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ class Set(base.CommandBase):
|
|||
self.host.quit(C.EXIT_BAD_ARG)
|
||||
path = os.path.abspath(path)
|
||||
try:
|
||||
await self.host.bridge.avatarSet(path, self.args.jid, self.profile)
|
||||
await self.host.bridge.avatar_set(path, self.args.jid, self.profile)
|
||||
except Exception as e:
|
||||
self.disp(f"can't set avatar: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class List(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
blocked_jids = await self.host.bridge.blockingList(
|
||||
blocked_jids = await self.host.bridge.blocking_list(
|
||||
self.profile,
|
||||
)
|
||||
except Exception as e:
|
||||
|
|
@ -72,7 +72,7 @@ class Block(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
await self.host.bridge.blockingBlock(
|
||||
await self.host.bridge.blocking_block(
|
||||
self.args.entities,
|
||||
self.profile
|
||||
)
|
||||
|
|
@ -108,7 +108,7 @@ class Unblock(base.CommandBase):
|
|||
async def start(self):
|
||||
if self.args.entities == ["all"]:
|
||||
if not self.args.force:
|
||||
await self.host.confirmOrQuit(
|
||||
await self.host.confirm_or_quit(
|
||||
_("All entities will be unblocked, are you sure"),
|
||||
_("unblock cancelled")
|
||||
)
|
||||
|
|
@ -117,7 +117,7 @@ class Unblock(base.CommandBase):
|
|||
self.parser.error(_('--force is only allowed when "all" is used as target'))
|
||||
|
||||
try:
|
||||
await self.host.bridge.blockingUnblock(
|
||||
await self.host.bridge.blocking_unblock(
|
||||
self.args.entities,
|
||||
self.profile
|
||||
)
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ RE_ATTACHMENT_METADATA = re.compile(r"^(?P<key>[a-z_]+)=(?P<value>.*)")
|
|||
ALLOWER_ATTACH_MD_KEY = ("desc", "media_type", "external")
|
||||
|
||||
|
||||
async def guessSyntaxFromPath(host, sat_conf, path):
|
||||
async def guess_syntax_from_path(host, sat_conf, path):
|
||||
"""Return syntax guessed according to filename extension
|
||||
|
||||
@param sat_conf(ConfigParser.ConfigParser): instance opened on sat configuration
|
||||
|
|
@ -107,7 +107,7 @@ async def guessSyntaxFromPath(host, sat_conf, path):
|
|||
return k
|
||||
|
||||
# if not found, we use current syntax
|
||||
return await host.bridge.getParamA("Syntax", "Composition", "value", host.profile)
|
||||
return await host.bridge.param_get_a("Syntax", "Composition", "value", host.profile)
|
||||
|
||||
|
||||
class BlogPublishCommon:
|
||||
|
|
@ -121,13 +121,13 @@ class BlogPublishCommon:
|
|||
"""
|
||||
if self.args.syntax is None:
|
||||
self.default_syntax_used = True
|
||||
return await self.host.bridge.getParamA(
|
||||
return await self.host.bridge.param_get_a(
|
||||
"Syntax", "Composition", "value", self.profile
|
||||
)
|
||||
else:
|
||||
self.default_syntax_used = False
|
||||
try:
|
||||
syntax = await self.host.bridge.syntaxGet(self.args.syntax)
|
||||
syntax = await self.host.bridge.syntax_get(self.args.syntax)
|
||||
self.current_syntax = self.args.syntax = syntax
|
||||
except Exception as e:
|
||||
if e.classname == "NotFound":
|
||||
|
|
@ -215,7 +215,7 @@ class BlogPublishCommon:
|
|||
elif self.current_syntax == SYNTAX_XHTML:
|
||||
mb_data["content_xhtml"] = content
|
||||
else:
|
||||
mb_data["content_xhtml"] = await self.host.bridge.syntaxConvert(
|
||||
mb_data["content_xhtml"] = await self.host.bridge.syntax_convert(
|
||||
content, self.current_syntax, SYNTAX_XHTML, False, self.profile
|
||||
)
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ class Set(base.CommandBase, BlogPublishCommon):
|
|||
await self.set_mb_data_content(content, mb_data)
|
||||
|
||||
try:
|
||||
item_id = await self.host.bridge.mbSend(
|
||||
item_id = await self.host.bridge.mb_send(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
data_format.serialise(mb_data),
|
||||
|
|
@ -381,7 +381,7 @@ class Get(base.CommandBase):
|
|||
return common.format_time(item["published"])
|
||||
|
||||
def format_url(self, item, keys):
|
||||
return uri.buildXMPPUri(
|
||||
return uri.build_xmpp_uri(
|
||||
"pubsub",
|
||||
subtype="microblog",
|
||||
path=self.metadata["service"],
|
||||
|
|
@ -509,12 +509,12 @@ class Get(base.CommandBase):
|
|||
async def start(self):
|
||||
try:
|
||||
mb_data = data_format.deserialise(
|
||||
await self.host.bridge.mbGet(
|
||||
await self.host.bridge.mb_get(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.max,
|
||||
self.args.items,
|
||||
self.getPubsubExtra(),
|
||||
self.get_pubsub_extra(),
|
||||
self.profile,
|
||||
)
|
||||
)
|
||||
|
|
@ -556,7 +556,7 @@ class Edit(base.CommandBase, BlogPublishCommon, common.BaseEdit):
|
|||
help=_('add "publish: False" to metadata'),
|
||||
)
|
||||
|
||||
def buildMetadataFile(self, content_file_path, mb_data=None):
|
||||
def build_metadata_file(self, content_file_path, mb_data=None):
|
||||
"""Build a metadata file using json
|
||||
|
||||
The file is named after content_file_path, with extension replaced by
|
||||
|
|
@ -620,7 +620,7 @@ class Edit(base.CommandBase, BlogPublishCommon, common.BaseEdit):
|
|||
async def edit(self, content_file_path, content_file_obj, mb_data=None):
|
||||
"""Edit the file contening the content using editor, and publish it"""
|
||||
# we first create metadata file
|
||||
meta_ori, meta_file_path = self.buildMetadataFile(content_file_path, mb_data)
|
||||
meta_ori, meta_file_path = self.build_metadata_file(content_file_path, mb_data)
|
||||
|
||||
coroutines = []
|
||||
|
||||
|
|
@ -646,7 +646,7 @@ class Edit(base.CommandBase, BlogPublishCommon, common.BaseEdit):
|
|||
|
||||
# we launch editor
|
||||
coroutines.append(
|
||||
self.runEditor(
|
||||
self.run_editor(
|
||||
"blog_editor_args",
|
||||
content_file_path,
|
||||
content_file_obj,
|
||||
|
|
@ -665,20 +665,20 @@ class Edit(base.CommandBase, BlogPublishCommon, common.BaseEdit):
|
|||
|
||||
mb_data = data_format.serialise(mb_data)
|
||||
|
||||
await self.host.bridge.mbSend(
|
||||
await self.host.bridge.mb_send(
|
||||
self.pubsub_service, self.pubsub_node, mb_data, self.profile
|
||||
)
|
||||
self.disp("Blog item published")
|
||||
|
||||
def getTmpSuff(self):
|
||||
def get_tmp_suff(self):
|
||||
# we get current syntax to determine file extension
|
||||
return SYNTAX_EXT.get(self.current_syntax, SYNTAX_EXT[""])
|
||||
|
||||
async def getItemData(self, service, node, item):
|
||||
async def get_item_data(self, service, node, item):
|
||||
items = [item] if item else []
|
||||
|
||||
mb_data = data_format.deserialise(
|
||||
await self.host.bridge.mbGet(
|
||||
await self.host.bridge.mb_get(
|
||||
service, node, 1, items, data_format.serialise({}), self.profile
|
||||
)
|
||||
)
|
||||
|
|
@ -689,12 +689,12 @@ class Edit(base.CommandBase, BlogPublishCommon, common.BaseEdit):
|
|||
except KeyError:
|
||||
content = item["content"]
|
||||
if content:
|
||||
content = await self.host.bridge.syntaxConvert(
|
||||
content = await self.host.bridge.syntax_convert(
|
||||
content, "text", SYNTAX_XHTML, False, self.profile
|
||||
)
|
||||
|
||||
if content and self.current_syntax != SYNTAX_XHTML:
|
||||
content = await self.host.bridge.syntaxConvert(
|
||||
content = await self.host.bridge.syntax_convert(
|
||||
content, SYNTAX_XHTML, self.current_syntax, False, self.profile
|
||||
)
|
||||
|
||||
|
|
@ -716,7 +716,7 @@ class Edit(base.CommandBase, BlogPublishCommon, common.BaseEdit):
|
|||
async def start(self):
|
||||
# if there are user defined extension, we use them
|
||||
SYNTAX_EXT.update(
|
||||
config.getConfig(self.sat_conf, C.CONFIG_SECTION, CONF_SYNTAX_EXT, {})
|
||||
config.config_get(self.sat_conf, C.CONFIG_SECTION, CONF_SYNTAX_EXT, {})
|
||||
)
|
||||
self.current_syntax = await self.get_current_syntax()
|
||||
|
||||
|
|
@ -727,7 +727,7 @@ class Edit(base.CommandBase, BlogPublishCommon, common.BaseEdit):
|
|||
content_file_path,
|
||||
content_file_obj,
|
||||
mb_data,
|
||||
) = await self.getItemPath()
|
||||
) = await self.get_item_path()
|
||||
|
||||
await self.edit(content_file_path, content_file_obj, mb_data=mb_data)
|
||||
self.host.quit()
|
||||
|
|
@ -749,7 +749,7 @@ class Rename(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
await self.host.bridge.mbRename(
|
||||
await self.host.bridge.mb_rename(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.item,
|
||||
|
|
@ -779,7 +779,7 @@ class Repeat(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
repeat_id = await self.host.bridge.mbRepeat(
|
||||
repeat_id = await self.host.bridge.mb_repeat(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.item,
|
||||
|
|
@ -821,13 +821,13 @@ class Preview(base.CommandBase, common.BaseEdit):
|
|||
help=_("path to the content file"),
|
||||
)
|
||||
|
||||
async def showPreview(self):
|
||||
# we implement showPreview here so we don't have to import webbrowser and urllib
|
||||
async def show_preview(self):
|
||||
# we implement show_preview here so we don't have to import webbrowser and urllib
|
||||
# when preview is not used
|
||||
url = "file:{}".format(self.urllib.parse.quote(self.preview_file_path))
|
||||
self.webbrowser.open_new_tab(url)
|
||||
|
||||
async def _launchPreviewExt(self, cmd_line, opt_name):
|
||||
async def _launch_preview_ext(self, cmd_line, opt_name):
|
||||
url = "file:{}".format(self.urllib.parse.quote(self.preview_file_path))
|
||||
args = common.parse_args(
|
||||
self.host, cmd_line, url=url, preview_file=self.preview_file_path
|
||||
|
|
@ -840,19 +840,19 @@ class Preview(base.CommandBase, common.BaseEdit):
|
|||
self.host.quit(1)
|
||||
subprocess.Popen(args)
|
||||
|
||||
async def openPreviewExt(self):
|
||||
await self._launchPreviewExt(self.open_cb_cmd, "blog_preview_open_cmd")
|
||||
async def open_preview_ext(self):
|
||||
await self._launch_preview_ext(self.open_cb_cmd, "blog_preview_open_cmd")
|
||||
|
||||
async def updatePreviewExt(self):
|
||||
await self._launchPreviewExt(self.update_cb_cmd, "blog_preview_update_cmd")
|
||||
async def update_preview_ext(self):
|
||||
await self._launch_preview_ext(self.update_cb_cmd, "blog_preview_update_cmd")
|
||||
|
||||
async def updateContent(self):
|
||||
async def update_content(self):
|
||||
with self.content_file_path.open("rb") as f:
|
||||
content = f.read().decode("utf-8-sig")
|
||||
if content and self.syntax != SYNTAX_XHTML:
|
||||
# we use safe=True because we want to have a preview as close as possible
|
||||
# to what the people will see
|
||||
content = await self.host.bridge.syntaxConvert(
|
||||
content = await self.host.bridge.syntax_convert(
|
||||
content, self.syntax, SYNTAX_XHTML, True, self.profile
|
||||
)
|
||||
|
||||
|
|
@ -896,30 +896,30 @@ class Preview(base.CommandBase, common.BaseEdit):
|
|||
|
||||
sat_conf = self.sat_conf
|
||||
SYNTAX_EXT.update(
|
||||
config.getConfig(sat_conf, C.CONFIG_SECTION, CONF_SYNTAX_EXT, {})
|
||||
config.config_get(sat_conf, C.CONFIG_SECTION, CONF_SYNTAX_EXT, {})
|
||||
)
|
||||
|
||||
try:
|
||||
self.open_cb_cmd = config.getConfig(
|
||||
self.open_cb_cmd = config.config_get(
|
||||
sat_conf, C.CONFIG_SECTION, "blog_preview_open_cmd", Exception
|
||||
)
|
||||
except (NoOptionError, NoSectionError):
|
||||
self.open_cb_cmd = None
|
||||
open_cb = self.showPreview
|
||||
open_cb = self.show_preview
|
||||
else:
|
||||
open_cb = self.openPreviewExt
|
||||
open_cb = self.open_preview_ext
|
||||
|
||||
self.update_cb_cmd = config.getConfig(
|
||||
self.update_cb_cmd = config.config_get(
|
||||
sat_conf, C.CONFIG_SECTION, "blog_preview_update_cmd", self.open_cb_cmd
|
||||
)
|
||||
if self.update_cb_cmd is None:
|
||||
update_cb = self.showPreview
|
||||
update_cb = self.show_preview
|
||||
else:
|
||||
update_cb = self.updatePreviewExt
|
||||
update_cb = self.update_preview_ext
|
||||
|
||||
# which file do we need to edit?
|
||||
if self.args.file == "current":
|
||||
self.content_file_path = self.getCurrentFile(self.profile)
|
||||
self.content_file_path = self.get_current_file(self.profile)
|
||||
else:
|
||||
try:
|
||||
self.content_file_path = Path(self.args.file).resolve(strict=True)
|
||||
|
|
@ -927,7 +927,7 @@ class Preview(base.CommandBase, common.BaseEdit):
|
|||
self.disp(_('File "{file}" doesn\'t exist!').format(file=self.args.file))
|
||||
self.host.quit(C.EXIT_NOT_FOUND)
|
||||
|
||||
self.syntax = await guessSyntaxFromPath(
|
||||
self.syntax = await guess_syntax_from_path(
|
||||
self.host, sat_conf, self.content_file_path
|
||||
)
|
||||
|
||||
|
|
@ -935,7 +935,7 @@ class Preview(base.CommandBase, common.BaseEdit):
|
|||
preview_file = tempfile.NamedTemporaryFile(suffix=".xhtml", delete=False)
|
||||
self.preview_file_path = preview_file.name
|
||||
preview_file.close()
|
||||
await self.updateContent()
|
||||
await self.update_content()
|
||||
|
||||
if aionotify is None:
|
||||
# XXX: we don't delete file automatically because browser needs it
|
||||
|
|
@ -989,7 +989,7 @@ class Preview(base.CommandBase, common.BaseEdit):
|
|||
# as a workaround, we do a little rest and try again
|
||||
await asyncio.sleep(1)
|
||||
await watcher.setup(loop)
|
||||
await self.updateContent()
|
||||
await self.update_content()
|
||||
await update_cb()
|
||||
except FileNotFoundError:
|
||||
self.disp("The file seems to have been deleted.", error=True)
|
||||
|
|
@ -1007,7 +1007,7 @@ class Preview(base.CommandBase, common.BaseEdit):
|
|||
|
||||
class Import(base.CommandBase):
|
||||
def __init__(self, host):
|
||||
super(Import, self).__init__(
|
||||
super().__init__(
|
||||
host,
|
||||
"import",
|
||||
use_pubsub=True,
|
||||
|
|
@ -1054,10 +1054,10 @@ class Import(base.CommandBase):
|
|||
),
|
||||
)
|
||||
|
||||
async def onProgressStarted(self, metadata):
|
||||
async def on_progress_started(self, metadata):
|
||||
self.disp(_("Blog upload started"), 2)
|
||||
|
||||
async def onProgressFinished(self, metadata):
|
||||
async def on_progress_finished(self, metadata):
|
||||
self.disp(_("Blog uploaded successfully"), 2)
|
||||
redirections = {
|
||||
k[len(URL_REDIRECT_PREFIX) :]: v
|
||||
|
|
@ -1085,7 +1085,7 @@ class Import(base.CommandBase):
|
|||
).format(conf=conf)
|
||||
)
|
||||
|
||||
async def onProgressError(self, error_msg):
|
||||
async def on_progress_error(self, error_msg):
|
||||
self.disp(
|
||||
_("Error while uploading blog: {error_msg}").format(error_msg=error_msg),
|
||||
error=True,
|
||||
|
|
@ -1163,12 +1163,12 @@ class AttachmentGet(cmd_pubsub.AttachmentGet):
|
|||
|
||||
def __init__(self, host):
|
||||
super().__init__(host)
|
||||
self.overridePubsubFlags({C.SERVICE, C.SINGLE_ITEM})
|
||||
self.override_pubsub_flags({C.SERVICE, C.SINGLE_ITEM})
|
||||
|
||||
|
||||
async def start(self):
|
||||
if not self.args.node:
|
||||
namespaces = await self.host.bridge.namespacesGet()
|
||||
namespaces = await self.host.bridge.namespaces_get()
|
||||
try:
|
||||
ns_microblog = namespaces["microblog"]
|
||||
except KeyError:
|
||||
|
|
@ -1183,11 +1183,11 @@ class AttachmentSet(cmd_pubsub.AttachmentSet):
|
|||
|
||||
def __init__(self, host):
|
||||
super().__init__(host)
|
||||
self.overridePubsubFlags({C.SERVICE, C.SINGLE_ITEM})
|
||||
self.override_pubsub_flags({C.SERVICE, C.SINGLE_ITEM})
|
||||
|
||||
async def start(self):
|
||||
if not self.args.node:
|
||||
namespaces = await self.host.bridge.namespacesGet()
|
||||
namespaces = await self.host.bridge.namespaces_get()
|
||||
try:
|
||||
ns_microblog = namespaces["microblog"]
|
||||
except KeyError:
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class BookmarksList(BookmarksCommon):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
data = await self.host.bridge.bookmarksList(
|
||||
data = await self.host.bridge.bookmarks_list(
|
||||
self.args.type, self.args.location, self.host.profile
|
||||
)
|
||||
except Exception as e:
|
||||
|
|
@ -107,10 +107,10 @@ class BookmarksRemove(BookmarksCommon):
|
|||
|
||||
async def start(self):
|
||||
if not self.args.force:
|
||||
await self.host.confirmOrQuit(_("Are you sure to delete this bookmark?"))
|
||||
await self.host.confirm_or_quit(_("Are you sure to delete this bookmark?"))
|
||||
|
||||
try:
|
||||
await self.host.bridge.bookmarksRemove(
|
||||
await self.host.bridge.bookmarks_remove(
|
||||
self.args.type, self.args.bookmark, self.args.location, self.host.profile
|
||||
)
|
||||
except Exception as e:
|
||||
|
|
@ -151,7 +151,7 @@ class BookmarksAdd(BookmarksCommon):
|
|||
if self.args.name is not None:
|
||||
data["name"] = self.args.name
|
||||
try:
|
||||
await self.host.bridge.bookmarksAdd(
|
||||
await self.host.bridge.bookmarks_add(
|
||||
self.args.type,
|
||||
self.args.bookmark,
|
||||
data,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ __commands__ = ["Debug"]
|
|||
|
||||
|
||||
class BridgeCommon(object):
|
||||
def evalArgs(self):
|
||||
def eval_args(self):
|
||||
if self.args.arg:
|
||||
try:
|
||||
return eval("[{}]".format(",".join(self.args.arg)))
|
||||
|
|
@ -67,7 +67,7 @@ class Method(base.CommandBase, BridgeCommon):
|
|||
elif "profile" in argspec.args:
|
||||
kwargs["profile"] = self.profile
|
||||
|
||||
args = self.evalArgs()
|
||||
args = self.eval_args()
|
||||
|
||||
try:
|
||||
ret = await method(
|
||||
|
|
@ -100,12 +100,12 @@ class Signal(base.CommandBase, BridgeCommon):
|
|||
self.parser.add_argument("arg", nargs="*", help=_("argument of the signal"))
|
||||
|
||||
async def start(self):
|
||||
args = self.evalArgs()
|
||||
args = self.eval_args()
|
||||
json_args = json.dumps(args)
|
||||
# XXX: we use self.args.profile and not self.profile
|
||||
# because we want the raw profile_key (so plugin handle C.PROF_KEY_NONE)
|
||||
try:
|
||||
await self.host.bridge.debugFakeSignal(
|
||||
await self.host.bridge.debug_signal_fake(
|
||||
self.args.signal, json_args, self.args.profile
|
||||
)
|
||||
except Exception as e:
|
||||
|
|
@ -115,11 +115,11 @@ class Signal(base.CommandBase, BridgeCommon):
|
|||
self.host.quit()
|
||||
|
||||
|
||||
class Bridge(base.CommandBase):
|
||||
class bridge(base.CommandBase):
|
||||
subcommands = (Method, Signal)
|
||||
|
||||
def __init__(self, host):
|
||||
super(Bridge, self).__init__(
|
||||
super(bridge, self).__init__(
|
||||
host, "bridge", use_profile=False, help=_("bridge s(t)imulation")
|
||||
)
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ class Monitor(base.CommandBase):
|
|||
help=_("stream direction filter"),
|
||||
)
|
||||
|
||||
async def printXML(self, direction, xml_data, profile):
|
||||
async def print_xml(self, direction, xml_data, profile):
|
||||
if self.args.direction == "in" and direction != "IN":
|
||||
return
|
||||
if self.args.direction == "out" and direction != "OUT":
|
||||
|
|
@ -186,7 +186,7 @@ class Monitor(base.CommandBase):
|
|||
self.disp("")
|
||||
|
||||
async def start(self):
|
||||
self.host.bridge.register_signal("xmlLog", self.printXML, "plugin")
|
||||
self.host.bridge.register_signal("xml_log", self.print_xml, "plugin")
|
||||
|
||||
|
||||
class Theme(base.CommandBase):
|
||||
|
|
@ -220,7 +220,7 @@ class Theme(base.CommandBase):
|
|||
|
||||
|
||||
class Debug(base.CommandBase):
|
||||
subcommands = (Bridge, Monitor, Theme)
|
||||
subcommands = (bridge, Monitor, Theme)
|
||||
|
||||
def __init__(self, host):
|
||||
super(Debug, self).__init__(
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class EncryptionAlgorithms(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
plugins_ser = await self.host.bridge.encryptionPluginsGet()
|
||||
plugins_ser = await self.host.bridge.encryption_plugins_get()
|
||||
plugins = data_format.deserialise(plugins_ser, type_check=list)
|
||||
except Exception as e:
|
||||
self.disp(f"can't retrieve plugins: {e}", error=True)
|
||||
|
|
@ -77,7 +77,7 @@ class EncryptionGet(base.CommandBase):
|
|||
jids = await self.host.check_jids([self.args.jid])
|
||||
jid = jids[0]
|
||||
try:
|
||||
serialised = await self.host.bridge.messageEncryptionGet(jid, self.profile)
|
||||
serialised = await self.host.bridge.message_encryption_get(jid, self.profile)
|
||||
except Exception as e:
|
||||
self.disp(f"can't get session: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
|
@ -117,7 +117,7 @@ class EncryptionStart(base.CommandBase):
|
|||
async def start(self):
|
||||
if self.args.name is not None:
|
||||
try:
|
||||
namespace = await self.host.bridge.encryptionNamespaceGet(self.args.name)
|
||||
namespace = await self.host.bridge.encryption_namespace_get(self.args.name)
|
||||
except Exception as e:
|
||||
self.disp(f"can't get encryption namespace: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
|
@ -130,7 +130,7 @@ class EncryptionStart(base.CommandBase):
|
|||
jid = jids[0]
|
||||
|
||||
try:
|
||||
await self.host.bridge.messageEncryptionStart(
|
||||
await self.host.bridge.message_encryption_start(
|
||||
jid, namespace, not self.args.encrypt_noreplace,
|
||||
self.profile)
|
||||
except Exception as e:
|
||||
|
|
@ -157,7 +157,7 @@ class EncryptionStop(base.CommandBase):
|
|||
jids = await self.host.check_jids([self.args.jid])
|
||||
jid = jids[0]
|
||||
try:
|
||||
await self.host.bridge.messageEncryptionStop(jid, self.profile)
|
||||
await self.host.bridge.message_encryption_stop(jid, self.profile)
|
||||
except Exception as e:
|
||||
self.disp(f"can't end encrypted session: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
|
@ -187,7 +187,7 @@ class TrustUI(base.CommandBase):
|
|||
async def start(self):
|
||||
if self.args.name is not None:
|
||||
try:
|
||||
namespace = await self.host.bridge.encryptionNamespaceGet(self.args.name)
|
||||
namespace = await self.host.bridge.encryption_namespace_get(self.args.name)
|
||||
except Exception as e:
|
||||
self.disp(f"can't get encryption namespace: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
|
@ -200,7 +200,7 @@ class TrustUI(base.CommandBase):
|
|||
jid = jids[0]
|
||||
|
||||
try:
|
||||
xmlui_raw = await self.host.bridge.encryptionTrustUIGet(
|
||||
xmlui_raw = await self.host.bridge.encryption_trust_ui_get(
|
||||
jid, namespace, self.profile)
|
||||
except Exception as e:
|
||||
self.disp(f"can't get encryption session trust UI: {e}", error=True)
|
||||
|
|
@ -209,7 +209,7 @@ class TrustUI(base.CommandBase):
|
|||
xmlui = xmlui_manager.create(self.host, xmlui_raw)
|
||||
await xmlui.show()
|
||||
if xmlui.type != C.XMLUI_DIALOG:
|
||||
await xmlui.submitForm()
|
||||
await xmlui.submit_form()
|
||||
self.host.quit()
|
||||
|
||||
class EncryptionTrust(base.CommandBase):
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@ class Get(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
events_data_s = await self.host.bridge.eventsGet(
|
||||
events_data_s = await self.host.bridge.events_get(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.items,
|
||||
self.getPubsubExtra(),
|
||||
self.get_pubsub_extra(),
|
||||
self.profile,
|
||||
)
|
||||
except Exception as e:
|
||||
|
|
@ -325,7 +325,7 @@ class Create(EventBase, base.CommandBase):
|
|||
if self.args.end is None:
|
||||
self.parser.error("--end or --duration must be set")
|
||||
try:
|
||||
await self.host.bridge.eventCreate(
|
||||
await self.host.bridge.event_create(
|
||||
data_format.serialise(event_data),
|
||||
self.args.id,
|
||||
self.args.node,
|
||||
|
|
@ -359,7 +359,7 @@ class Modify(EventBase, base.CommandBase):
|
|||
async def start(self):
|
||||
event_data = self.get_event_data()
|
||||
try:
|
||||
await self.host.bridge.eventModify(
|
||||
await self.host.bridge.event_modify(
|
||||
data_format.serialise(event_data),
|
||||
self.args.item,
|
||||
self.args.service,
|
||||
|
|
@ -394,7 +394,7 @@ class InviteeGet(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
event_data_s = await self.host.bridge.eventInviteeGet(
|
||||
event_data_s = await self.host.bridge.event_invitee_get(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.item,
|
||||
|
|
@ -436,7 +436,7 @@ class InviteeSet(base.CommandBase):
|
|||
# TODO: handle RSVP with XMLUI in a similar way as for `ad-hoc run`
|
||||
fields = dict(self.args.fields) if self.args.fields else {}
|
||||
try:
|
||||
self.host.bridge.eventInviteeSet(
|
||||
self.host.bridge.event_invitee_set(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.item,
|
||||
|
|
@ -522,7 +522,7 @@ class InviteesList(base.CommandBase):
|
|||
|
||||
show_table = OUTPUT_OPT_TABLE in self.args.output_opts
|
||||
|
||||
table = common.Table.fromListDict(
|
||||
table = common.Table.from_list_dict(
|
||||
self.host,
|
||||
data,
|
||||
("nick",) + (("jid",) if self.host.verbosity else ()) + ("attend", "guests"),
|
||||
|
|
@ -596,7 +596,7 @@ class InviteesList(base.CommandBase):
|
|||
else:
|
||||
# we get prefilled data with all people
|
||||
try:
|
||||
affiliations = await self.host.bridge.psNodeAffiliationsGet(
|
||||
affiliations = await self.host.bridge.ps_node_affiliations_get(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.profile,
|
||||
|
|
@ -615,7 +615,7 @@ class InviteesList(base.CommandBase):
|
|||
}
|
||||
|
||||
try:
|
||||
event_data = await self.host.bridge.eventInviteesList(
|
||||
event_data = await self.host.bridge.event_invitees_list(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.profile,
|
||||
|
|
@ -647,7 +647,7 @@ class InviteesList(base.CommandBase):
|
|||
|
||||
# we get nicknames for everybody, make it easier for organisers
|
||||
for jid_, data in prefilled.items():
|
||||
id_data = await self.host.bridge.identityGet(jid_, [], True, self.profile)
|
||||
id_data = await self.host.bridge.identity_get(jid_, [], True, self.profile)
|
||||
id_data = data_format.deserialise(id_data)
|
||||
data["nick"] = id_data["nicknames"][0]
|
||||
|
||||
|
|
@ -716,7 +716,7 @@ class InviteeInvite(base.CommandBase):
|
|||
emails_extra = self.args.email[1:]
|
||||
|
||||
try:
|
||||
await self.host.bridge.eventInviteByEmail(
|
||||
await self.host.bridge.event_invite_by_email(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.item,
|
||||
|
|
|
|||
|
|
@ -82,19 +82,19 @@ class Send(base.CommandBase):
|
|||
help=_("end-to-end encrypt the file transfer")
|
||||
)
|
||||
|
||||
async def onProgressStarted(self, metadata):
|
||||
async def on_progress_started(self, metadata):
|
||||
self.disp(_("File copy started"), 2)
|
||||
|
||||
async def onProgressFinished(self, metadata):
|
||||
async def on_progress_finished(self, metadata):
|
||||
self.disp(_("File sent successfully"), 2)
|
||||
|
||||
async def onProgressError(self, error_msg):
|
||||
async def on_progress_error(self, error_msg):
|
||||
if error_msg == C.PROGRESS_ERROR_DECLINED:
|
||||
self.disp(_("The file has been refused by your contact"))
|
||||
else:
|
||||
self.disp(_("Error while sending file: {}").format(error_msg), error=True)
|
||||
|
||||
async def gotId(self, data, file_):
|
||||
async def got_id(self, data, file_):
|
||||
"""Called when a progress id has been received
|
||||
|
||||
@param pid(unicode): progress id
|
||||
|
|
@ -134,7 +134,7 @@ class Send(base.CommandBase):
|
|||
|
||||
if self.args.bz2:
|
||||
with tempfile.NamedTemporaryFile("wb", delete=False) as buf:
|
||||
self.host.addOnQuitCallback(os.unlink, buf.name)
|
||||
self.host.add_on_quit_callback(os.unlink, buf.name)
|
||||
self.disp(_("bz2 is an experimental option, use with caution"))
|
||||
# FIXME: check free space
|
||||
self.disp(_("Starting compression, please wait..."))
|
||||
|
|
@ -150,7 +150,7 @@ class Send(base.CommandBase):
|
|||
self.disp(_("Done !"), 1)
|
||||
|
||||
try:
|
||||
send_data = await self.host.bridge.fileSend(
|
||||
send_data = await self.host.bridge.file_send(
|
||||
self.args.jid,
|
||||
buf.name,
|
||||
self.args.name or archive_name,
|
||||
|
|
@ -162,12 +162,12 @@ class Send(base.CommandBase):
|
|||
self.disp(f"can't send file: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
else:
|
||||
await self.gotId(send_data, file_)
|
||||
await self.got_id(send_data, file_)
|
||||
else:
|
||||
for file_ in self.args.files:
|
||||
path = os.path.abspath(file_)
|
||||
try:
|
||||
send_data = await self.host.bridge.fileSend(
|
||||
send_data = await self.host.bridge.file_send(
|
||||
self.args.jid,
|
||||
path,
|
||||
self.args.name,
|
||||
|
|
@ -179,7 +179,7 @@ class Send(base.CommandBase):
|
|||
self.disp(f"can't send file {file_!r}: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
else:
|
||||
await self.gotId(send_data, file_)
|
||||
await self.got_id(send_data, file_)
|
||||
|
||||
|
||||
class Request(base.CommandBase):
|
||||
|
|
@ -241,13 +241,13 @@ class Request(base.CommandBase):
|
|||
help=_("overwrite existing file without confirmation"),
|
||||
)
|
||||
|
||||
async def onProgressStarted(self, metadata):
|
||||
async def on_progress_started(self, metadata):
|
||||
self.disp(_("File copy started"), 2)
|
||||
|
||||
async def onProgressFinished(self, metadata):
|
||||
async def on_progress_finished(self, metadata):
|
||||
self.disp(_("File received successfully"), 2)
|
||||
|
||||
async def onProgressError(self, error_msg):
|
||||
async def on_progress_error(self, error_msg):
|
||||
if error_msg == C.PROGRESS_ERROR_DECLINED:
|
||||
self.disp(_("The file request has been refused"))
|
||||
else:
|
||||
|
|
@ -267,7 +267,7 @@ class Request(base.CommandBase):
|
|||
message = _("File {path} already exists! Do you want to overwrite?").format(
|
||||
path=path
|
||||
)
|
||||
await self.host.confirmOrQuit(message, _("file request cancelled"))
|
||||
await self.host.confirm_or_quit(message, _("file request cancelled"))
|
||||
|
||||
self.full_dest_jid = await self.host.get_full_jid(self.args.jid)
|
||||
extra = {}
|
||||
|
|
@ -276,7 +276,7 @@ class Request(base.CommandBase):
|
|||
if self.args.namespace:
|
||||
extra["namespace"] = self.args.namespace
|
||||
try:
|
||||
progress_id = await self.host.bridge.fileJingleRequest(
|
||||
progress_id = await self.host.bridge.file_jingle_request(
|
||||
self.full_dest_jid,
|
||||
path,
|
||||
self.args.name,
|
||||
|
|
@ -303,9 +303,9 @@ class Receive(base.CommandAnswering):
|
|||
)
|
||||
self._overwrite_refused = False # True when one overwrite as already been refused
|
||||
self.action_callbacks = {
|
||||
C.META_TYPE_FILE: self.onFileAction,
|
||||
C.META_TYPE_OVERWRITE: self.onOverwriteAction,
|
||||
C.META_TYPE_NOT_IN_ROSTER_LEAK: self.onNotInRosterAction,
|
||||
C.META_TYPE_FILE: self.on_file_action,
|
||||
C.META_TYPE_OVERWRITE: self.on_overwrite_action,
|
||||
C.META_TYPE_NOT_IN_ROSTER_LEAK: self.on_not_in_roster_action,
|
||||
}
|
||||
|
||||
def add_parser_options(self):
|
||||
|
|
@ -335,10 +335,10 @@ class Receive(base.CommandAnswering):
|
|||
help=_("destination path (default: working directory)"),
|
||||
)
|
||||
|
||||
async def onProgressStarted(self, metadata):
|
||||
async def on_progress_started(self, metadata):
|
||||
self.disp(_("File copy started"), 2)
|
||||
|
||||
async def onProgressFinished(self, metadata):
|
||||
async def on_progress_finished(self, metadata):
|
||||
self.disp(_("File received successfully"), 2)
|
||||
if metadata.get("hash_verified", False):
|
||||
try:
|
||||
|
|
@ -350,10 +350,10 @@ class Receive(base.CommandAnswering):
|
|||
else:
|
||||
self.disp(_("hash can't be verified"), 1)
|
||||
|
||||
async def onProgressError(self, e):
|
||||
async def on_progress_error(self, e):
|
||||
self.disp(_("Error while receiving file: {e}").format(e=e), error=True)
|
||||
|
||||
def getXmluiId(self, action_data):
|
||||
def get_xmlui_id(self, action_data):
|
||||
# FIXME: we temporarily use ElementTree, but a real XMLUI managing module
|
||||
# should be available in the futur
|
||||
# TODO: XMLUI module
|
||||
|
|
@ -368,10 +368,10 @@ class Receive(base.CommandAnswering):
|
|||
self.disp(_("Invalid XMLUI received"), error=True)
|
||||
return xmlui_id
|
||||
|
||||
async def onFileAction(self, action_data, action_id, security_limit, profile):
|
||||
xmlui_id = self.getXmluiId(action_data)
|
||||
async def on_file_action(self, action_data, action_id, security_limit, profile):
|
||||
xmlui_id = self.get_xmlui_id(action_data)
|
||||
if xmlui_id is None:
|
||||
return self.host.quitFromSignal(1)
|
||||
return self.host.quit_from_signal(1)
|
||||
try:
|
||||
from_jid = jid.JID(action_data["meta_from_jid"])
|
||||
except KeyError:
|
||||
|
|
@ -386,18 +386,18 @@ class Receive(base.CommandAnswering):
|
|||
if not self.bare_jids or from_jid.bare in self.bare_jids:
|
||||
if self._overwrite_refused:
|
||||
self.disp(_("File refused because overwrite is needed"), error=True)
|
||||
await self.host.bridge.launchAction(
|
||||
await self.host.bridge.action_launch(
|
||||
xmlui_id, {"cancelled": C.BOOL_TRUE}, profile_key=profile
|
||||
)
|
||||
return self.host.quitFromSignal(2)
|
||||
return self.host.quit_from_signal(2)
|
||||
await self.set_progress_id(progress_id)
|
||||
xmlui_data = {"path": self.path}
|
||||
await self.host.bridge.launchAction(xmlui_id, xmlui_data, profile_key=profile)
|
||||
await self.host.bridge.action_launch(xmlui_id, xmlui_data, profile_key=profile)
|
||||
|
||||
async def onOverwriteAction(self, action_data, action_id, security_limit, profile):
|
||||
xmlui_id = self.getXmluiId(action_data)
|
||||
async def on_overwrite_action(self, action_data, action_id, security_limit, profile):
|
||||
xmlui_id = self.get_xmlui_id(action_data)
|
||||
if xmlui_id is None:
|
||||
return self.host.quitFromSignal(1)
|
||||
return self.host.quit_from_signal(1)
|
||||
try:
|
||||
progress_id = action_data["meta_progress_id"]
|
||||
except KeyError:
|
||||
|
|
@ -412,13 +412,13 @@ class Receive(base.CommandAnswering):
|
|||
self.disp(_("Refused to overwrite"), 2)
|
||||
self._overwrite_refused = True
|
||||
|
||||
xmlui_data = {"answer": C.boolConst(self.args.force)}
|
||||
await self.host.bridge.launchAction(xmlui_id, xmlui_data, profile_key=profile)
|
||||
xmlui_data = {"answer": C.bool_const(self.args.force)}
|
||||
await self.host.bridge.action_launch(xmlui_id, xmlui_data, profile_key=profile)
|
||||
|
||||
async def onNotInRosterAction(self, action_data, action_id, security_limit, profile):
|
||||
xmlui_id = self.getXmluiId(action_data)
|
||||
async def on_not_in_roster_action(self, action_data, action_id, security_limit, profile):
|
||||
xmlui_id = self.get_xmlui_id(action_data)
|
||||
if xmlui_id is None:
|
||||
return self.host.quitFromSignal(1)
|
||||
return self.host.quit_from_signal(1)
|
||||
try:
|
||||
from_jid = jid.JID(action_data["meta_from_jid"])
|
||||
except ValueError:
|
||||
|
|
@ -442,11 +442,11 @@ class Receive(base.CommandAnswering):
|
|||
xmlui = xmlui_manager.create(self.host, action_data["xmlui"])
|
||||
confirmed = await self.host.confirm(xmlui.dlg.message)
|
||||
|
||||
xmlui_data = {"answer": C.boolConst(confirmed)}
|
||||
await self.host.bridge.launchAction(xmlui_id, xmlui_data, profile_key=profile)
|
||||
xmlui_data = {"answer": C.bool_const(confirmed)}
|
||||
await self.host.bridge.action_launch(xmlui_id, xmlui_data, profile_key=profile)
|
||||
if not confirmed and not self.args.multiple:
|
||||
self.disp(_("Session refused for {from_jid}").format(from_jid=from_jid))
|
||||
self.host.quitFromSignal(0)
|
||||
self.host.quit_from_signal(0)
|
||||
|
||||
async def start(self):
|
||||
self.bare_jids = [jid.JID(jid_).bare for jid_ in self.args.jids]
|
||||
|
|
@ -489,16 +489,16 @@ class Get(base.CommandBase):
|
|||
help=_("URI of the file to retrieve or JSON of the whole attachment")
|
||||
)
|
||||
|
||||
async def onProgressStarted(self, metadata):
|
||||
async def on_progress_started(self, metadata):
|
||||
self.disp(_("File download started"), 2)
|
||||
|
||||
async def onProgressFinished(self, metadata):
|
||||
async def on_progress_finished(self, metadata):
|
||||
self.disp(_("File downloaded successfully"), 2)
|
||||
|
||||
async def onProgressError(self, error_msg):
|
||||
async def on_progress_error(self, error_msg):
|
||||
self.disp(_("Error while downloading file: {}").format(error_msg), error=True)
|
||||
|
||||
async def gotId(self, data):
|
||||
async def got_id(self, data):
|
||||
"""Called when a progress id has been received"""
|
||||
try:
|
||||
await self.set_progress_id(data["progress"])
|
||||
|
|
@ -532,12 +532,12 @@ class Get(base.CommandBase):
|
|||
message = _("File {path} already exists! Do you want to overwrite?").format(
|
||||
path=dest_file
|
||||
)
|
||||
await self.host.confirmOrQuit(message, _("file download cancelled"))
|
||||
await self.host.confirm_or_quit(message, _("file download cancelled"))
|
||||
|
||||
options = {}
|
||||
|
||||
try:
|
||||
download_data_s = await self.host.bridge.fileDownload(
|
||||
download_data_s = await self.host.bridge.file_download(
|
||||
data_format.serialise(attachment),
|
||||
str(dest_file),
|
||||
data_format.serialise(options),
|
||||
|
|
@ -548,7 +548,7 @@ class Get(base.CommandBase):
|
|||
self.disp(f"error while trying to download a file: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
else:
|
||||
await self.gotId(download_data)
|
||||
await self.got_id(download_data)
|
||||
|
||||
|
||||
class Upload(base.CommandBase):
|
||||
|
|
@ -576,10 +576,10 @@ class Upload(base.CommandBase):
|
|||
help=_(r"ignore invalide TLS certificate (/!\ Dangerous /!\)"),
|
||||
)
|
||||
|
||||
async def onProgressStarted(self, metadata):
|
||||
async def on_progress_started(self, metadata):
|
||||
self.disp(_("File upload started"), 2)
|
||||
|
||||
async def onProgressFinished(self, metadata):
|
||||
async def on_progress_finished(self, metadata):
|
||||
self.disp(_("File uploaded successfully"), 2)
|
||||
try:
|
||||
url = metadata["url"]
|
||||
|
|
@ -590,10 +590,10 @@ class Upload(base.CommandBase):
|
|||
# XXX: url is displayed alone on a line to make parsing easier
|
||||
self.disp(url)
|
||||
|
||||
async def onProgressError(self, error_msg):
|
||||
async def on_progress_error(self, error_msg):
|
||||
self.disp(_("Error while uploading file: {}").format(error_msg), error=True)
|
||||
|
||||
async def gotId(self, data, file_):
|
||||
async def got_id(self, data, file_):
|
||||
"""Called when a progress id has been received
|
||||
|
||||
@param pid(unicode): progress id
|
||||
|
|
@ -633,7 +633,7 @@ class Upload(base.CommandBase):
|
|||
|
||||
path = os.path.abspath(file_)
|
||||
try:
|
||||
upload_data = await self.host.bridge.fileUpload(
|
||||
upload_data = await self.host.bridge.file_upload(
|
||||
path,
|
||||
"",
|
||||
self.full_dest_jid,
|
||||
|
|
@ -644,7 +644,7 @@ class Upload(base.CommandBase):
|
|||
self.disp(f"error while trying to upload a file: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
else:
|
||||
await self.gotId(upload_data, file_)
|
||||
await self.got_id(upload_data, file_)
|
||||
|
||||
|
||||
class ShareAffiliationsSet(base.CommandBase):
|
||||
|
|
@ -687,7 +687,7 @@ class ShareAffiliationsSet(base.CommandBase):
|
|||
async def start(self):
|
||||
affiliations = dict(self.args.affiliations)
|
||||
try:
|
||||
affiliations = await self.host.bridge.FISAffiliationsSet(
|
||||
affiliations = await self.host.bridge.fis_affiliations_set(
|
||||
self.args.jid,
|
||||
self.args.namespace,
|
||||
self.args.path,
|
||||
|
|
@ -730,7 +730,7 @@ class ShareAffiliationsGet(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
affiliations = await self.host.bridge.FISAffiliationsGet(
|
||||
affiliations = await self.host.bridge.fis_affiliations_get(
|
||||
self.args.jid,
|
||||
self.args.namespace,
|
||||
self.args.path,
|
||||
|
|
@ -793,7 +793,7 @@ class ShareConfigurationSet(base.CommandBase):
|
|||
async def start(self):
|
||||
configuration = dict(self.args.fields)
|
||||
try:
|
||||
configuration = await self.host.bridge.FISConfigurationSet(
|
||||
configuration = await self.host.bridge.fis_configuration_set(
|
||||
self.args.jid,
|
||||
self.args.namespace,
|
||||
self.args.path,
|
||||
|
|
@ -836,7 +836,7 @@ class ShareConfigurationGet(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
configuration = await self.host.bridge.FISConfigurationGet(
|
||||
configuration = await self.host.bridge.fis_configuration_get(
|
||||
self.args.jid,
|
||||
self.args.namespace,
|
||||
self.args.path,
|
||||
|
|
@ -900,7 +900,7 @@ class ShareList(base.CommandBase):
|
|||
def _size_filter(self, size, row):
|
||||
if not size:
|
||||
return ""
|
||||
return A.color(A.BOLD, utils.getHumanSize(size))
|
||||
return A.color(A.BOLD, utils.get_human_size(size))
|
||||
|
||||
def default_output(self, files_data):
|
||||
"""display files a way similar to ls"""
|
||||
|
|
@ -914,7 +914,7 @@ class ShareList(base.CommandBase):
|
|||
show_header = True
|
||||
keys = ("name", "type", "size", "file_hash")
|
||||
headers = ("name", "type", "size", "hash")
|
||||
table = common.Table.fromListDict(
|
||||
table = common.Table.from_list_dict(
|
||||
self.host,
|
||||
files_data,
|
||||
keys=keys,
|
||||
|
|
@ -926,7 +926,7 @@ class ShareList(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
files_data = await self.host.bridge.FISList(
|
||||
files_data = await self.host.bridge.fis_list(
|
||||
self.args.jid,
|
||||
self.args.path,
|
||||
{},
|
||||
|
|
@ -987,7 +987,7 @@ class SharePath(base.CommandBase):
|
|||
else:
|
||||
access = {}
|
||||
try:
|
||||
name = await self.host.bridge.FISSharePath(
|
||||
name = await self.host.bridge.fis_share_path(
|
||||
self.args.name,
|
||||
self.path,
|
||||
json.dumps(access, ensure_ascii=False),
|
||||
|
|
@ -1059,7 +1059,7 @@ class ShareInvite(base.CommandBase):
|
|||
else:
|
||||
extra["thumb_url"] = self.args.thumbnail
|
||||
try:
|
||||
await self.host.bridge.FISInvite(
|
||||
await self.host.bridge.fis_invite(
|
||||
self.args.jid,
|
||||
self.args.service,
|
||||
self.args.type,
|
||||
|
|
|
|||
|
|
@ -54,13 +54,13 @@ class Edit(base.CommandBase, common.BaseEdit):
|
|||
help=_("forum key (DEFAULT: default forums)"),
|
||||
)
|
||||
|
||||
def getTmpSuff(self):
|
||||
def get_tmp_suff(self):
|
||||
"""return suffix used for content file"""
|
||||
return "json"
|
||||
|
||||
async def publish(self, forums_raw):
|
||||
try:
|
||||
await self.host.bridge.forumsSet(
|
||||
await self.host.bridge.forums_set(
|
||||
forums_raw,
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
|
|
@ -76,7 +76,7 @@ class Edit(base.CommandBase, common.BaseEdit):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
forums_json = await self.host.bridge.forumsGet(
|
||||
forums_json = await self.host.bridge.forums_get(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.key,
|
||||
|
|
@ -89,7 +89,7 @@ class Edit(base.CommandBase, common.BaseEdit):
|
|||
self.disp(f"can't get node configuration: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
||||
content_file_obj, content_file_path = self.getTmpFile()
|
||||
content_file_obj, content_file_path = self.get_tmp_file()
|
||||
forums_json = forums_json.strip()
|
||||
if forums_json:
|
||||
# we loads and dumps to have pretty printed json
|
||||
|
|
@ -98,7 +98,7 @@ class Edit(base.CommandBase, common.BaseEdit):
|
|||
f = codecs.getwriter("utf-8")(content_file_obj)
|
||||
json.dump(forums, f, ensure_ascii=False, indent=4)
|
||||
content_file_obj.seek(0)
|
||||
await self.runEditor("forums_editor_args", content_file_path, content_file_obj)
|
||||
await self.run_editor("forums_editor_args", content_file_path, content_file_obj)
|
||||
|
||||
|
||||
class Get(base.CommandBase):
|
||||
|
|
@ -154,7 +154,7 @@ class Get(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
forums_raw = await self.host.bridge.forumsGet(
|
||||
forums_raw = await self.host.bridge.forums_get(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.key,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class Get(base.CommandBase):
|
|||
async def start(self):
|
||||
jid_ = (await self.host.check_jids([self.args.jid]))[0]
|
||||
try:
|
||||
data = await self.host.bridge.identityGet(
|
||||
data = await self.host.bridge.identity_get(
|
||||
jid_,
|
||||
[],
|
||||
not self.args.no_cache,
|
||||
|
|
@ -91,7 +91,7 @@ class Set(base.CommandBase):
|
|||
if not id_data:
|
||||
self.parser.error("At least one metadata must be set")
|
||||
try:
|
||||
self.host.bridge.identitySet(
|
||||
self.host.bridge.identity_set(
|
||||
data_format.serialise(id_data),
|
||||
self.profile,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ class Disco(base.CommandBase):
|
|||
# infos
|
||||
if infos_requested:
|
||||
try:
|
||||
infos = await self.host.bridge.discoInfos(
|
||||
infos = await self.host.bridge.disco_infos(
|
||||
jid,
|
||||
node=self.args.node,
|
||||
use_cache=self.args.use_cache,
|
||||
|
|
@ -251,7 +251,7 @@ class Disco(base.CommandBase):
|
|||
# items
|
||||
if items_requested:
|
||||
try:
|
||||
items = await self.host.bridge.discoItems(
|
||||
items = await self.host.bridge.disco_items(
|
||||
jid,
|
||||
node=self.args.node,
|
||||
use_cache=self.args.use_cache,
|
||||
|
|
@ -298,7 +298,7 @@ class Version(base.CommandBase):
|
|||
jids = await self.host.check_jids([self.args.jid])
|
||||
jid = jids[0]
|
||||
try:
|
||||
data = await self.host.bridge.getSoftwareVersion(jid, self.host.profile)
|
||||
data = await self.host.bridge.software_version_get(jid, self.host.profile)
|
||||
except Exception as e:
|
||||
self.disp(_("error while trying to get version: {e}").format(e=e), error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
|
@ -340,7 +340,7 @@ class Session(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
data = await self.host.bridge.sessionInfosGet(self.host.profile)
|
||||
data = await self.host.bridge.session_infos_get(self.host.profile)
|
||||
except Exception as e:
|
||||
self.disp(_("Error getting session infos: {e}").format(e=e), error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
|
@ -362,7 +362,7 @@ class Devices(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
data = await self.host.bridge.devicesInfosGet(
|
||||
data = await self.host.bridge.devices_infos_get(
|
||||
self.args.jid, self.host.profile
|
||||
)
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class InputCommon(base.CommandBase):
|
|||
def opt(self, type_):
|
||||
return lambda s: (type_, s)
|
||||
|
||||
def addValue(self, value):
|
||||
def add_value(self, value):
|
||||
"""add a parsed value according to arguments sequence"""
|
||||
self._values_ori.append(value)
|
||||
arguments = self.args.arguments
|
||||
|
|
@ -329,7 +329,7 @@ class Csv(InputCommon):
|
|||
if idx < self.args.row:
|
||||
continue
|
||||
for value in row:
|
||||
self.addValue(value)
|
||||
self.add_value(value)
|
||||
await self.runCommand()
|
||||
except exceptions.CancelError:
|
||||
# this row has been cancelled, we skip it
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class Create(base.CommandBase):
|
|||
)
|
||||
|
||||
try:
|
||||
invitation_data = await self.host.bridge.invitationCreate(
|
||||
invitation_data = await self.host.bridge.invitation_create(
|
||||
email,
|
||||
emails_extra,
|
||||
self.args.jid,
|
||||
|
|
@ -178,7 +178,7 @@ class Get(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
invitation_data = await self.host.bridge.invitationGet(
|
||||
invitation_data = await self.host.bridge.invitation_get(
|
||||
self.args.id,
|
||||
)
|
||||
except Exception as e:
|
||||
|
|
@ -190,7 +190,7 @@ class Get(base.CommandBase):
|
|||
else:
|
||||
profile = invitation_data["guest_profile"]
|
||||
try:
|
||||
await self.host.bridge.profileStartSession(
|
||||
await self.host.bridge.profile_start_session(
|
||||
invitation_data["password"],
|
||||
profile,
|
||||
)
|
||||
|
|
@ -199,7 +199,7 @@ class Get(base.CommandBase):
|
|||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
||||
try:
|
||||
jid_ = await self.host.bridge.asyncGetParamA(
|
||||
jid_ = await self.host.bridge.param_get_a_async(
|
||||
"JabberID",
|
||||
"Connection",
|
||||
profile_key=profile,
|
||||
|
|
@ -226,7 +226,7 @@ class Delete(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
await self.host.bridge.invitationDelete(
|
||||
await self.host.bridge.invitation_delete(
|
||||
self.args.id,
|
||||
)
|
||||
except Exception as e:
|
||||
|
|
@ -302,7 +302,7 @@ class Modify(base.CommandBase):
|
|||
)
|
||||
extra[arg_name] = value
|
||||
try:
|
||||
await self.host.bridge.invitationModify(
|
||||
await self.host.bridge.invitation_modify(
|
||||
self.args.id,
|
||||
extra,
|
||||
self.args.replace,
|
||||
|
|
@ -348,7 +348,7 @@ class List(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
data = await self.host.bridge.invitationList(
|
||||
data = await self.host.bridge.invitation_list(
|
||||
self.args.profile,
|
||||
)
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ class Get(base.CommandBase):
|
|||
await common.fill_well_known_uri(self, os.getcwd(), "tickets", meta_map={})
|
||||
try:
|
||||
lists_data = data_format.deserialise(
|
||||
await self.host.bridge.listGet(
|
||||
await self.host.bridge.list_get(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.max,
|
||||
self.args.items,
|
||||
"",
|
||||
self.getPubsubExtra(),
|
||||
self.get_pubsub_extra(),
|
||||
self.profile,
|
||||
),
|
||||
type_check=list,
|
||||
|
|
@ -123,7 +123,7 @@ class Set(base.CommandBase):
|
|||
extra = {"update": update}
|
||||
|
||||
try:
|
||||
item_id = await self.host.bridge.listSet(
|
||||
item_id = await self.host.bridge.list_set(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
values,
|
||||
|
|
@ -171,9 +171,9 @@ class Delete(base.CommandBase):
|
|||
message = _("Are you sure to delete list item {item_id} ?").format(
|
||||
item_id=self.args.item
|
||||
)
|
||||
await self.host.confirmOrQuit(message, _("item deletion cancelled"))
|
||||
await self.host.confirm_or_quit(message, _("item deletion cancelled"))
|
||||
try:
|
||||
await self.host.bridge.listDeleteItem(
|
||||
await self.host.bridge.list_delete_item(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.item,
|
||||
|
|
@ -192,7 +192,7 @@ class Import(base.CommandBase):
|
|||
# TODO: factorize with blog/import
|
||||
|
||||
def __init__(self, host):
|
||||
super(Import, self).__init__(
|
||||
super().__init__(
|
||||
host,
|
||||
"import",
|
||||
use_progress=True,
|
||||
|
|
@ -253,13 +253,13 @@ class Import(base.CommandBase):
|
|||
),
|
||||
)
|
||||
|
||||
async def onProgressStarted(self, metadata):
|
||||
async def on_progress_started(self, metadata):
|
||||
self.disp(_("Tickets upload started"), 2)
|
||||
|
||||
async def onProgressFinished(self, metadata):
|
||||
async def on_progress_finished(self, metadata):
|
||||
self.disp(_("Tickets uploaded successfully"), 2)
|
||||
|
||||
async def onProgressError(self, error_msg):
|
||||
async def on_progress_error(self, error_msg):
|
||||
self.disp(
|
||||
_("Error while uploading tickets: {error_msg}").format(error_msg=error_msg),
|
||||
error=True,
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class Set(base.CommandBase):
|
|||
"You are going to publish your changes to service "
|
||||
"[{service}], are you sure ?"
|
||||
).format(service=self.args.service)
|
||||
await self.host.confirmOrQuit(
|
||||
await self.host.confirm_or_quit(
|
||||
message, _("merge request publication cancelled")
|
||||
)
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class Set(base.CommandBase):
|
|||
if self.args.labels is not None:
|
||||
values["labels"] = self.args.labels
|
||||
try:
|
||||
published_id = await self.host.bridge.mergeRequestSet(
|
||||
published_id = await self.host.bridge.merge_request_set(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.repository,
|
||||
|
|
@ -133,7 +133,7 @@ class Get(base.CommandBase):
|
|||
extra = {}
|
||||
try:
|
||||
requests_data = data_format.deserialise(
|
||||
await self.host.bridge.mergeRequestsGet(
|
||||
await self.host.bridge.merge_requests_get(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.max,
|
||||
|
|
@ -186,7 +186,7 @@ class Import(base.CommandBase):
|
|||
)
|
||||
extra = {}
|
||||
try:
|
||||
await self.host.bridge.mergeRequestsImport(
|
||||
await self.host.bridge.merge_requests_import(
|
||||
self.repository,
|
||||
self.args.item,
|
||||
self.args.service,
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class Send(base.CommandBase):
|
|||
"jid", help=_("the destination jid")
|
||||
)
|
||||
|
||||
async def sendStdin(self, dest_jid):
|
||||
async def send_stdin(self, dest_jid):
|
||||
"""Send incomming data on stdin to jabber contact
|
||||
|
||||
@param dest_jid: destination jid
|
||||
|
|
@ -123,7 +123,7 @@ class Send(base.CommandBase):
|
|||
if header:
|
||||
# first we sent the header
|
||||
try:
|
||||
await self.host.bridge.messageSend(
|
||||
await self.host.bridge.message_send(
|
||||
dest_jid,
|
||||
{self.args.lang: header},
|
||||
subject,
|
||||
|
|
@ -160,7 +160,7 @@ class Send(base.CommandBase):
|
|||
# first one
|
||||
del extra[C.KEY_ATTACHMENTS]
|
||||
try:
|
||||
await self.host.bridge.messageSend(
|
||||
await self.host.bridge.message_send(
|
||||
dest_jid,
|
||||
msg,
|
||||
subject,
|
||||
|
|
@ -193,21 +193,21 @@ class Send(base.CommandBase):
|
|||
|
||||
if self.args.encrypt is not None:
|
||||
try:
|
||||
namespace = await self.host.bridge.encryptionNamespaceGet(
|
||||
namespace = await self.host.bridge.encryption_namespace_get(
|
||||
self.args.encrypt)
|
||||
except Exception as e:
|
||||
self.disp(f"can't get encryption namespace: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
||||
try:
|
||||
await self.host.bridge.messageEncryptionStart(
|
||||
await self.host.bridge.message_encryption_start(
|
||||
jid_, namespace, not self.args.encrypt_noreplace, self.profile
|
||||
)
|
||||
except Exception as e:
|
||||
self.disp(f"can't start encryption session: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
||||
await self.sendStdin(jid_)
|
||||
await self.send_stdin(jid_)
|
||||
|
||||
|
||||
class Retract(base.CommandBase):
|
||||
|
|
@ -223,7 +223,7 @@ class Retract(base.CommandBase):
|
|||
|
||||
async def start(self):
|
||||
try:
|
||||
await self.host.bridge.messageRetract(
|
||||
await self.host.bridge.message_retract(
|
||||
self.args.message_id,
|
||||
self.profile
|
||||
)
|
||||
|
|
@ -286,7 +286,7 @@ class MAM(base.CommandBase):
|
|||
if value is not None:
|
||||
extra[key] = str(value)
|
||||
try:
|
||||
data, metadata_s, profile = await self.host.bridge.MAMGet(
|
||||
data, metadata_s, profile = await self.host.bridge.mam_get(
|
||||
self.args.service, data_format.serialise(extra), self.profile)
|
||||
except Exception as e:
|
||||
self.disp(f"can't retrieve MAM archives: {e}", error=True)
|
||||
|
|
@ -295,7 +295,7 @@ class MAM(base.CommandBase):
|
|||
metadata = data_format.deserialise(metadata_s)
|
||||
|
||||
try:
|
||||
session_info = await self.host.bridge.sessionInfosGet(self.profile)
|
||||
session_info = await self.host.bridge.session_infos_get(self.profile)
|
||||
except Exception as e:
|
||||
self.disp(f"can't get session infos: {e}", error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue