comparison frontends/src/jp/base.py @ 2313:6ff5212997c7

jp (shell): use of subprocess instead of running commands in the same process: when a command is calling host.quit() in a D-Bus callback, GLib mainloop is exiting and quit the whole process without (apparently?) any way to block it. Couldn't find a good way to avoid that, so subprocess are now used as a workaround, instead of launching commands in the same process. When we'll get rid of python-dbus, there may be an other way. Execuring external commands is now possible through the shell/! command.
author Goffi <goffi@goffi.org>
date Fri, 07 Jul 2017 22:33:55 +0200
parents eaff25529c53
children 3865a772c360
comparison
equal deleted inserted replaced
2312:eaff25529c53 2313:6ff5212997c7
163 log.error(u"Can't import {} bridge".format(bridge_name)) 163 log.error(u"Can't import {} bridge".format(bridge_name))
164 sys.exit(1) 164 sys.exit(1)
165 165
166 self.bridge = bridge_module.Bridge() 166 self.bridge = bridge_module.Bridge()
167 self.bridge.bridgeConnect(callback=self._bridgeCb, errback=self._bridgeEb) 167 self.bridge.bridgeConnect(callback=self._bridgeCb, errback=self._bridgeEb)
168 # _no_exit is used in shell mode because SystemExit can't
169 # catched in some cases
170 self._no_exit = False
171 168
172 def _bridgeCb(self): 169 def _bridgeCb(self):
173 self.parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, 170 self.parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
174 description=DESCRIPTION) 171 description=DESCRIPTION)
175 self._make_parents() 172 self._make_parents()
443 else: 440 else:
444 for callback, args, kwargs in callbacks_list: 441 for callback, args, kwargs in callbacks_list:
445 callback(*args, **kwargs) 442 callback(*args, **kwargs)
446 443
447 self.stop_loop() 444 self.stop_loop()
448 if not self._no_exit: 445 sys.exit(errcode)
449 sys.exit(errcode)
450 446
451 def check_jids(self, jids): 447 def check_jids(self, jids):
452 """Check jids validity, transform roster name to corresponding jids 448 """Check jids validity, transform roster name to corresponding jids
453 449
454 @param profile: profile name 450 @param profile: profile name