# HG changeset patch # User Goffi # Date 1456761171 -3600 # Node ID 6d9c87bdc452df3904bcc0df249ff7713986b366 # Parent 3b2a236fa7433c537abebd033d0ea9c0011a6835 jp (base): added a CommandBase.start method which is called by run or connected, so subclasses can implement it (this is for simplicity sake, as it's not always clear if run or connected must be used) diff -r 3b2a236fa743 -r 6d9c87bdc452 frontends/src/jp/base.py --- a/frontends/src/jp/base.py Mon Feb 29 16:52:51 2016 +0100 +++ b/frontends/src/jp/base.py Mon Feb 29 16:52:51 2016 +0100 @@ -583,9 +583,11 @@ 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 @@ 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):