changeset 1860:afc7f6328394

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
author Goffi <goffi@goffi.org>
date Mon, 29 Feb 2016 16:52:51 +0100
parents ac2ac7fe8a9b
children 3b2a236fa743
files frontends/src/jp/base.py
diffstat 1 files changed, 5 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/jp/base.py	Mon Feb 29 16:13:47 2016 +0100
+++ b/frontends/src/jp/base.py	Mon Feb 29 16:52:51 2016 +0100
@@ -427,6 +427,9 @@
             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 @@
             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