diff frontends/src/jp/cmd_profile.py @ 1864:96ba685162f6

jp: all commands now use the new start method and set need_loop in __init__ when needed
author Goffi <goffi@goffi.org>
date Mon, 29 Feb 2016 16:52:51 +0100
parents 3b2a236fa743
children 227a4e617549 3e168cde7a7d
line wrap: on
line diff
--- a/frontends/src/jp/cmd_profile.py	Mon Feb 29 16:52:51 2016 +0100
+++ b/frontends/src/jp/cmd_profile.py	Mon Feb 29 16:52:51 2016 +0100
@@ -48,7 +48,7 @@
     def add_parser_options(self):
         pass
 
-    def run(self):
+    def start(self):
         print self.host.bridge.getProfileName('@DEFAULT@')
 
 
@@ -60,8 +60,7 @@
         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 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 @@
             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 @@
     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 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 @@
     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 @@
                                  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: