jp (base): use need_connect attribue to detect if connection is needed instead of self.args.profile, as profile argument can be used by any command even if use_profile is False
This commit is contained in:
parent
8403bd61ae
commit
fea3296b89
1 changed files with 5 additions and 8 deletions
|
|
@ -427,6 +427,9 @@ class CommandBase(object):
|
|||
parents.add(self.host.parents['profile' if need_connect else 'profile_session'])
|
||||
else:
|
||||
assert need_connect is None
|
||||
self.need_connect = need_connect
|
||||
# from this point, self.need_connect is None if connection is not needed at all
|
||||
# False if session starting is needed, and True if full connection is needed
|
||||
|
||||
if use_progress:
|
||||
parents.add(self.host.parents['progress'])
|
||||
|
|
@ -580,14 +583,8 @@ class CommandBase(object):
|
|||
cls(self)
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
if self.args.profile:
|
||||
connect_profile = self.host.connect_profile
|
||||
except AttributeError:
|
||||
# the command doesn't need to connect profile
|
||||
pass
|
||||
else:
|
||||
connect_profile(self.connected)
|
||||
if self.need_connect is not None:
|
||||
self.host.connect_profile(self.connected)
|
||||
|
||||
try:
|
||||
show_progress = self.args.progress
|
||||
|
|
|
|||
Loading…
Reference in a new issue