jp: all commands now use the new start method and set need_loop in __init__ when needed
This commit is contained in:
parent
89f6fe8605
commit
169bc43793
1 changed files with 46 additions and 84 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue