Mercurial > libervia-backend
comparison frontends/src/jp/base.py @ 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 | 9eabf7fadfdd |
children | 6d9c87bdc452 |
comparison
equal
deleted
inserted
replaced
1859:ac2ac7fe8a9b | 1860:afc7f6328394 |
---|---|
425 if need_connect is None: | 425 if need_connect is None: |
426 need_connect = True | 426 need_connect = True |
427 parents.add(self.host.parents['profile' if need_connect else 'profile_session']) | 427 parents.add(self.host.parents['profile' if need_connect else 'profile_session']) |
428 else: | 428 else: |
429 assert need_connect is None | 429 assert need_connect is None |
430 self.need_connect = need_connect | |
431 # from this point, self.need_connect is None if connection is not needed at all | |
432 # False if session starting is needed, and True if full connection is needed | |
430 | 433 |
431 if use_progress: | 434 if use_progress: |
432 parents.add(self.host.parents['progress']) | 435 parents.add(self.host.parents['progress']) |
433 | 436 |
434 if use_verbose: | 437 if use_verbose: |
578 # now we add subcommands to ourself | 581 # now we add subcommands to ourself |
579 for cls in subcommands: | 582 for cls in subcommands: |
580 cls(self) | 583 cls(self) |
581 | 584 |
582 def run(self): | 585 def run(self): |
583 try: | 586 if self.need_connect is not None: |
584 if self.args.profile: | 587 self.host.connect_profile(self.connected) |
585 connect_profile = self.host.connect_profile | |
586 except AttributeError: | |
587 # the command doesn't need to connect profile | |
588 pass | |
589 else: | |
590 connect_profile(self.connected) | |
591 | 588 |
592 try: | 589 try: |
593 show_progress = self.args.progress | 590 show_progress = self.args.progress |
594 except AttributeError: | 591 except AttributeError: |
595 # the command doesn't use progress bar | 592 # the command doesn't use progress bar |