Mercurial > libervia-backend
diff frontends/src/jp/base.py @ 2550:1d754bc14381
jp (base): new confirmOrQuit helper method to ask confirmation to user, and quit if he cancel
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 31 Mar 2018 18:21:56 +0200 |
parents | 2d69a0afe039 |
children | 38e1e29c48e9 |
line wrap: on
line diff
--- a/frontends/src/jp/base.py Sat Mar 31 17:20:38 2018 +0200 +++ b/frontends/src/jp/base.py Sat Mar 31 18:21:56 2018 +0200 @@ -546,6 +546,14 @@ except AttributeError: pass + def confirmOrQuit(self, message, cancel_message=_(u"action cancelled by user")): + """Request user to confirm action, and quit if he doesn't""" + + res = raw_input("{} (y/N)? ".format(message)) + if res not in ("y", "Y"): + self.disp(cancel_message) + self.quit(C.EXIT_USER_CANCELLED) + def quitFromSignal(self, errcode=0): """Same as self.quit, but from a signal handler