diff --git a/frontends/src/jp/base.py b/frontends/src/jp/base.py index 596754fb..69bf2f2e 100644 --- a/frontends/src/jp/base.py +++ b/frontends/src/jp/base.py @@ -583,9 +583,11 @@ class CommandBase(object): cls(self) def run(self): - if self.need_connect is not None: - self.host.connect_profile(self.connected) + """this method is called when a command is actually run + It set stuff like progression callbacks and profile connection + You should not overide this method: you should call self.start instead + """ try: show_progress = self.args.progress except AttributeError: @@ -599,9 +601,29 @@ class CommandBase(object): self.host.bridge.register("progressFinished", self.progressFinishedHandler) self.host.bridge.register("progressError", self.progressErrorHandler) + if self.need_connect is not None: + self.host.connect_profile(self.connected) + else: + self.start() + def connected(self): + """this method is called when profile is connected (or session is started) + + this method is only called when use_profile is True + most of time you should override self.start instead of this method, but if loop + if not always needed depending on your arguments, you may override this method, + but don't forget to call the parent one (i.e. this one) after self.need_loop is set + """ if not self.need_loop: self.host.stop_loop() + self.start() + + def start(self): + """This is the starting point of the command, this method should be overriden + + at this point, profile are connected if needed + """ + pass class CommandAnswering(CommandBase):