diff --git a/frontends/src/jp/cmd_adhoc.py b/frontends/src/jp/cmd_adhoc.py
index 183324aa..15b92001 100644
--- a/frontends/src/jp/cmd_adhoc.py
+++ b/frontends/src/jp/cmd_adhoc.py
@@ -17,11 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-from logging import debug, info, error, warning
-
import base
-import sys
-import os
from sat.core.i18n import _
__commands__ = ["AdHoc"]
@@ -31,7 +27,7 @@ MAGIC_BAREJID = '@PROFILE_BAREJID@'
class Remote(base.CommandBase):
def __init__(self, host):
- super(Remote, self).__init__(host, 'remote', help=_('Remote control a software'))
+ super(Remote, self).__init__(host, 'remote', use_verbose=True, help=_('Remote control a software'))
def add_parser_options(self):
self.parser.add_argument("software", type=str, help=_("Software name"))
@@ -41,8 +37,7 @@ class Remote(base.CommandBase):
self.parser.add_argument("--forbidden-jids", type=base.unicode_decoder, nargs='*', default=[], help=_("Jids that are *NOT* allowed to use the command"))
self.parser.add_argument("-l", "--loop", action="store_true", help=_("Loop on the commands"))
- def connected(self):
- super(Remote, self).connected()
+ def start(self):
name = self.args.software.lower()
flags = []
magics = {jid for jid in self.args.jids if jid.count('@')>1}
@@ -53,13 +48,13 @@ class Remote(base.CommandBase):
bus_name, methods = self.host.bridge.adHocDBusAddAuto(name, jids, self.args.groups, magics,
self.args.forbidden_jids, self.args.forbidden_groups,
flags, self.profile)
- debug(_("Bus name found: [%s]" % bus_name))
+ self.disp(_("Bus name found: [%s]" % bus_name), 1)
for method in methods:
path, iface, command = method
- debug (_("Command found: (path:%(path)s, iface: %(iface)s) [%(command)s]" % {'path': path,
+ self.disp(_("Command found: (path:%(path)s, iface: %(iface)s) [%(command)s]" % {'path': path,
'iface': iface,
'command': command
- }))
+ }),1)
class AdHoc(base.CommandBase):
subcommands = (Remote,)
diff --git a/frontends/src/jp/cmd_blog.py b/frontends/src/jp/cmd_blog.py
index f1c6c772..72965adc 100644
--- a/frontends/src/jp/cmd_blog.py
+++ b/frontends/src/jp/cmd_blog.py
@@ -30,6 +30,7 @@ __commands__ = ["Blog"]
class Import(base.CommandAnswering):
def __init__(self, host):
super(Import, self).__init__(host, 'import', use_progress=True, help=_(u'import an external blog'))
+ self.need_loop=True
def add_parser_options(self):
self.parser.add_argument("importer", type=base.unicode_decoder, nargs='?', help=_(u"importer name, nothing to display importers list"))
@@ -67,11 +68,7 @@ class Import(base.CommandAnswering):
self.disp(_("Error while trying to upload a blog: {reason}").format(reason=failure), error=True)
self.host.quit(1)
- def connected(self):
- """Send files to jabber contact"""
- self.need_loop=True
- super(Import, self).connected()
-
+ def start(self):
if self.args.location is None:
for name in ('option', 'service', 'no_images_upload'):
if getattr(self.args, name):
@@ -108,7 +105,7 @@ class Import(base.CommandAnswering):
class Blog(base.CommandBase):
- subcommands = (Import,)
+ subcommands = (Edit, Import)
def __init__(self, host):
super(Blog, self).__init__(host, 'blog', use_profile=False, help=_('blog/microblog management'))
diff --git a/frontends/src/jp/cmd_bookmarks.py b/frontends/src/jp/cmd_bookmarks.py
index 8f4ee79c..f533201d 100644
--- a/frontends/src/jp/cmd_bookmarks.py
+++ b/frontends/src/jp/cmd_bookmarks.py
@@ -17,8 +17,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-from logging import debug, info, error, warning
-
import base
from sat.core.i18n import _
@@ -43,8 +41,7 @@ class BookmarksList(BookmarksCommon):
def __init__(self, host):
super(BookmarksList, self).__init__(host, 'list', help=_('list bookmarks'))
- def connected(self):
- super(BookmarksList, self).connected()
+ def start(self):
data = self.host.bridge.bookmarksList(self.args.type, self.args.location, self.host.profile)
mess = []
for location in STORAGE_LOCATIONS:
@@ -68,17 +65,16 @@ class BookmarksList(BookmarksCommon):
class BookmarksRemove(BookmarksCommon):
- need_loop = True
def __init__(self, host):
super(BookmarksRemove, self).__init__(host, 'remove', help=_('remove a bookmark'))
+ self.need_loop = True
def add_parser_options(self):
super(BookmarksRemove, self).add_parser_options()
self.parser.add_argument('bookmark', type=base.unicode_decoder, help=_('jid (for muc bookmark) or url of to remove'))
- def connected(self):
- super(BookmarksRemove, self).connected()
+ def start(self):
self.host.bridge.bookmarksRemove(self.args.type, self.args.bookmark, self.args.location, self.host.profile, callback = lambda: self.host.quit(), errback=self._errback)
@@ -86,6 +82,7 @@ class BookmarksAdd(BookmarksCommon):
def __init__(self, host):
super(BookmarksAdd, self).__init__(host, 'add', help=_('add a bookmark'))
+ self.need_loop = True
def add_parser_options(self):
super(BookmarksAdd, self).add_parser_options(location_default='auto')
@@ -95,9 +92,7 @@ class BookmarksAdd(BookmarksCommon):
muc_group.add_argument('-N', '--nick', type=base.unicode_decoder, help=_('nickname'))
muc_group.add_argument('-a', '--autojoin', action='store_true', help=_('join room on profile connection'))
- def connected(self):
- self.need_loop = True
- super(BookmarksAdd, self).connected()
+ def start(self):
if self.args.type == 'url' and (self.args.autojoin or self.args.nick is not None):
# XXX: Argparse doesn't seem to manage this case, any better way ?
print _(u"You can't use --autojoin or --nick with --type url")
diff --git a/frontends/src/jp/cmd_file.py b/frontends/src/jp/cmd_file.py
index af64cb23..78d46457 100644
--- a/frontends/src/jp/cmd_file.py
+++ b/frontends/src/jp/cmd_file.py
@@ -36,16 +36,15 @@ __commands__ = ["File"]
class Send(base.CommandBase):
def __init__(self, host):
super(Send, self).__init__(host, 'send', use_progress=True, use_verbose=True, help=_('Send a file to a contact'))
+ self.need_loop=True
def add_parser_options(self):
self.parser.add_argument("files", type=str, nargs='+', metavar='file', help=_("a list of file"))
self.parser.add_argument("jid", type=base.unicode_decoder, help=_("the destination jid"))
self.parser.add_argument("-b", "--bz2", action="store_true", help=_("make a bzip2 tarball"))
- def connected(self):
+ def start(self):
"""Send files to jabber contact"""
- self.need_loop=True
- super(Send, self).connected()
self.send_files()
def onProgressStarted(self, metadata):
@@ -203,8 +202,7 @@ class Receive(base.CommandAnswering):
self.parser.add_argument("-f", "--force", action="store_true", help=_(u"force overwritting of existing files (/!\\ name is choosed by sended)"))
self.parser.add_argument("--path", default='.', metavar='DIR', help=_(u"destination path (default: working directory)"))
- def run(self):
- super(Receive, self).run()
+ def start(self):
self.bare_jids = [jid.JID(jid_).bare for jid_ in self.args.jids]
self.path = os.path.abspath(self.args.path)
if not os.path.isdir(self.path):
@@ -216,20 +214,16 @@ class Receive(base.CommandAnswering):
class Upload(base.CommandBase):
+
def __init__(self, host):
super(Upload, self).__init__(host, 'upload', use_progress=True, use_verbose=True, help=_('Upload a file'))
+ self.need_loop=True
def add_parser_options(self):
self.parser.add_argument("file", type=str, help=_("file to upload"))
self.parser.add_argument("jid", type=base.unicode_decoder, nargs='?', help=_("jid of upload component (nothing to autodetect)"))
self.parser.add_argument("--ignore-tls-errors", action="store_true", help=_("ignore invalide TLS certificate"))
- def connected(self):
- """Send files to jabber contact"""
- self.need_loop=True
- super(Upload, self).connected()
- self.uploadFile()
-
def onProgressStarted(self, metadata):
self.disp(_(u'File upload started'),2)
@@ -264,7 +258,7 @@ class Upload(base.CommandBase):
self.disp(_("Error while trying to upload a file: {reason}").format(reason=failure), error=True)
self.host.quit(1)
- def uploadFile(self):
+ def start(self):
file_ = self.args.file
if not os.path.exists(file_):
self.disp(_(u"file [{}] doesn't exist !").format(file_), error=True)
diff --git a/frontends/src/jp/cmd_info.py b/frontends/src/jp/cmd_info.py
index 03347ae0..8ae16989 100644
--- a/frontends/src/jp/cmd_info.py
+++ b/frontends/src/jp/cmd_info.py
@@ -17,8 +17,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-from logging import debug, info, warning
-
import base
from sat.core.i18n import _
@@ -29,13 +27,12 @@ class Disco(base.CommandBase):
def __init__(self, host):
super(Disco, self).__init__(host, 'disco', help=_('Service discovery'))
+ self.need_loop=True
def add_parser_options(self):
self.parser.add_argument("jid", type=str, help=_("Entity to discover"))
- def connected(self):
- self.need_loop=True
- super(Disco, self).connected()
+ def start(self):
jids = self.host.check_jids([self.args.jid])
jid = jids[0]
self.host.bridge.discoInfos(jid, profile_key=self.host.profile, callback=lambda infos: self.gotInfos(infos, jid), errback=self.error)
@@ -108,13 +105,12 @@ class Version(base.CommandBase):
def __init__(self, host):
super(Version, self).__init__(host, 'version', help=_('Client version'))
+ self.need_loop=True
def add_parser_options(self):
self.parser.add_argument("jid", type=str, help=_("Entity to request"))
- def connected(self):
- self.need_loop=True
- super(Version, self).connected()
+ def start(self):
jids = self.host.check_jids([self.args.jid])
jid = jids[0]
self.host.bridge.getSoftwareVersion(jid, self.host.profile, callback=self.gotVersion, errback=self.error)
diff --git a/frontends/src/jp/cmd_message.py b/frontends/src/jp/cmd_message.py
index 52f816b5..6d53cba3 100644
--- a/frontends/src/jp/cmd_message.py
+++ b/frontends/src/jp/cmd_message.py
@@ -35,8 +35,7 @@ class Send(base.CommandBase):
self.parser.add_argument("-n", "--new-line", action="store_true", help=_("add a new line at the beginning of the input (usefull for ascii art ;))"))
self.parser.add_argument("jid", type=str, help=_("the destination jid"))
- def connected(self):
- super(Send, self).connected()
+ def start(self):
jids = self.host.check_jids([self.args.jid])
jid = jids[0]
self.sendStdin(jid)
diff --git a/frontends/src/jp/cmd_param.py b/frontends/src/jp/cmd_param.py
index d32fc49b..afa73ca9 100644
--- a/frontends/src/jp/cmd_param.py
+++ b/frontends/src/jp/cmd_param.py
@@ -34,8 +34,7 @@ class Get(base.CommandBase):
self.parser.add_argument("-a", "--attribute", type=str, default="value", help=_(u"Name of the attribute to get"))
self.parser.add_argument("--security-limit", type=int, default=-1, help=_(u"Security limit"))
- def connected(self):
- super(Get, self).connected()
+ def start(self):
if self.args.category is None:
categories = self.host.bridge.getParamsCategories()
print u"\n".join(categories)
@@ -67,8 +66,7 @@ class Set(base.CommandBase):
self.parser.add_argument("value", type=base.unicode_decoder, help=_(u"Name of the parameter"))
self.parser.add_argument("--security-limit", type=int, default=-1, help=_(u"Security limit"))
- def connected(self):
- super(Set, self).connected()
+ def start(self):
try:
self.host.bridge.setParam(self.args.name, self.args.value, self.args.category, self.args.security_limit, self.profile)
except Exception as e:
@@ -82,7 +80,7 @@ class SaveTemplate(base.CommandBase):
def add_parser_options(self):
self.parser.add_argument("filename", type=str, help=_("Output file"))
- def run(self):
+ def start(self):
"""Save parameters template to xml file"""
if self.host.bridge.saveParamsTemplate(self.args.filename):
print _("Parameters saved to file %s") % self.args.filename
@@ -98,7 +96,7 @@ class LoadTemplate(base.CommandBase):
def add_parser_options(self):
self.parser.add_argument("filename", type=str, help=_("Input file"))
- def run(self):
+ def start(self):
"""Load parameters template from xml file"""
if self.host.bridge.loadParamsTemplate(self.args.filename):
print _("Parameters loaded from file %s") % self.args.filename
diff --git a/frontends/src/jp/cmd_pipe.py b/frontends/src/jp/cmd_pipe.py
index 43b20bcb..117c1537 100644
--- a/frontends/src/jp/cmd_pipe.py
+++ b/frontends/src/jp/cmd_pipe.py
@@ -36,12 +36,14 @@ class PipeOut(base.CommandBase):
def __init__(self, host):
super(PipeOut, self).__init__(host, 'out', help=_('send a pipe a stream'))
+ self.need_loop = True
def add_parser_options(self):
self.parser.add_argument("jid", type=base.unicode_decoder, help=_("the destination jid"))
- def pipe_out(self):
+ def start(self):
""" Create named pipe, and send stdin to it """
+ # TODO: check_jids
tmp_dir = tempfile.mkdtemp()
fifopath = os.path.join(tmp_dir,"pipe_out")
os.mkfifo(fifopath)
@@ -51,12 +53,6 @@ class PipeOut(base.CommandBase):
shutil.rmtree(tmp_dir)
self.host.quit()
- def connected(self):
- # TODO: check_jids
- self.need_loop = True
- super(PipeOut, self).connected()
- self.pipe_out()
-
class PipeIn(base.CommandAnswering):
@@ -104,8 +100,7 @@ class PipeIn(base.CommandAnswering):
shutil.rmtree(tmp_dir)
self.host.quit()
- def run(self):
- super(PipeIn, self).run()
+ def start(self):
self.bare_jids = [jid.JID(jid_).bare for jid_ in self.args.jids]
diff --git a/frontends/src/jp/cmd_profile.py b/frontends/src/jp/cmd_profile.py
index 6062cf59..9f5461df 100644
--- a/frontends/src/jp/cmd_profile.py
+++ b/frontends/src/jp/cmd_profile.py
@@ -48,7 +48,7 @@ class ProfileDefault(base.CommandBase):
def add_parser_options(self):
pass
- def run(self):
+ def start(self):
print self.host.bridge.getProfileName('@DEFAULT@')
@@ -60,8 +60,7 @@ class ProfileDelete(base.CommandBase):
self.parser.add_argument('profile', type=str, help=PROFILE_HELP)
self.parser.add_argument('-f', '--force', action='store_true', help=_(u'delete profile without confirmation'))
- def run(self):
- super(ProfileDelete, self).run()
+ def start(self):
if self.args.profile not in self.host.bridge.getProfilesList():
log.error("Profile %s doesn't exist." % self.args.profile)
self.host.quit(1)
@@ -78,6 +77,7 @@ class ProfileDelete(base.CommandBase):
class ProfileInfo(base.CommandBase):
def __init__(self, host):
super(ProfileInfo, self).__init__(host, 'info', need_connect=False, help=_('get information about a profile'))
+ self.need_loop = True
self.to_show = [(_(u"jid"), "Connection", "JabberID"),]
self.largest = max([len(item[0]) for item in self.to_show])
@@ -97,9 +97,7 @@ class ProfileInfo(base.CommandBase):
self.host.bridge.asyncGetParamA(name, category, profile_key=self.host.profile,
callback=lambda value: self.showNextValue(label, category, value))
- def connected(self):
- self.need_loop = True
- super(ProfileInfo, self).connected()
+ def start(self):
if self.args.show_password:
self.to_show.append((_(u"XMPP password"), "Connection", "Password"))
self.showNextValue()
@@ -112,8 +110,7 @@ class ProfileList(base.CommandBase):
def add_parser_options(self):
pass
- def run(self):
- super(ProfileList, self).run()
+ def start(self):
for profile in self.host.bridge.getProfilesList():
print profile
@@ -121,6 +118,7 @@ class ProfileList(base.CommandBase):
class ProfileCreate(base.CommandBase):
def __init__(self, host):
super(ProfileCreate, self).__init__(host, 'create', use_profile=False, help=_('create a new profile'))
+ self.need_loop = True
def add_parser_options(self):
self.parser.add_argument('profile', type=str, help=_('the name of the profile'))
@@ -140,9 +138,8 @@ class ProfileCreate(base.CommandBase):
def _profile_created(self):
self.host.bridge.profileStartSession(self.args.password, self.args.profile, callback=self._session_started, errback=None)
- def run(self):
+ def start(self):
"""Create a new profile"""
- self.need_loop = True
if self.args.profile in self.host.bridge.getProfilesList():
log.error("Profile %s already exists." % self.args.profile)
self.host.quit(1)
@@ -162,8 +159,7 @@ class ProfileModify(base.CommandBase):
metavar='PASSWORD')
self.parser.add_argument('-D', '--default', action='store_true', help=_(u'set as default profile'))
- def connected(self):
- super(ProfileModify, self).connected()
+ def start(self):
if self.args.disable_password:
self.args.password = ''
if self.args.password is not None:
diff --git a/frontends/src/jp/cmd_roster.py b/frontends/src/jp/cmd_roster.py
index b8f6326b..9f31ed70 100644
--- a/frontends/src/jp/cmd_roster.py
+++ b/frontends/src/jp/cmd_roster.py
@@ -33,14 +33,13 @@ class Purge(base.CommandBase):
def __init__(self, host):
super(Purge, self).__init__(host, 'purge', help=_('Purge the roster from its contacts with no subscription'))
+ self.need_loop = True
def add_parser_options(self):
self.parser.add_argument("--no_from", action="store_true", help=_("Also purge contacts with no 'from' subscription"))
self.parser.add_argument("--no_to", action="store_true", help=_("Also purge contacts with no 'to' subscription"))
- def connected(self):
- self.need_loop = True
- super(Purge, self).connected()
+ def start(self):
self.host.bridge.getContacts(profile_key=self.host.profile, callback=self.gotContacts, errback=self.error)
def error(self, failure):
@@ -99,13 +98,12 @@ class Stats(base.CommandBase):
def __init__(self, host):
super(Stats, self).__init__(host, 'stats', help=_('Show statistics about a roster'))
+ self.need_loop = True
def add_parser_options(self):
pass
- def connected(self):
- self.need_loop = True
- super(Stats, self).connected()
+ def start(self):
self.host.bridge.getContacts(profile_key=self.host.profile, callback=self.gotContacts, errback=self.error)
def error(self, failure):
@@ -161,15 +159,14 @@ class Get(base.CommandBase):
def __init__(self, host):
super(Get, self).__init__(host, 'get', help=_('Retrieve the roster contacts'))
+ self.need_loop = True
def add_parser_options(self):
self.parser.add_argument("--subscriptions", action="store_true", help=_("Show the contacts' subscriptions"))
self.parser.add_argument("--groups", action="store_true", help=_("Show the contacts' groups"))
self.parser.add_argument("--name", action="store_true", help=_("Show the contacts' names"))
- def connected(self):
- self.need_loop = True
- super(Get, self).connected()
+ def start(self):
self.host.bridge.getContacts(profile_key=self.host.profile, callback=self.gotContacts, errback=self.error)
def error(self, failure):