From 054423d016ebbf01dd70b2899a9e6d78d1c5f7ad Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 13 Nov 2011 20:17:50 +0200 Subject: [PATCH] Use YesNoQuestion in pbuilder-dist --- pbuilder-dist | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/pbuilder-dist b/pbuilder-dist index 8ce0320..3f8e787 100755 --- a/pbuilder-dist +++ b/pbuilder-dist @@ -37,6 +37,8 @@ from distro_info import DebianDistroInfo import ubuntutools.misc from ubuntutools import subprocess +from ubuntutools.question import YesNoQuestion + class PbuilderDist: def __init__(self, builder): @@ -135,9 +137,10 @@ class PbuilderDist: # Debian experimental doesn't have a debootstrap file but # should work nevertheless. if distro not in self._debian_distros: - answer = ask(('Warning: Unknown distribution "%s". Do you ' - 'want to continue [y/N]? ') % distro) - if answer not in ('y', 'Y'): + answer = YesNoQuestion().ask( + 'Warning: Unknown distribution "%s". ' + 'Do you want to continue' % distro, 'no') + if answer == 'yes': sys.exit(0) else: Logger.error('Please install package "debootstrap".') @@ -297,22 +300,6 @@ class PbuilderDist: self.builder, ] + arguments - -def ask(question): - """ ask(question) -> string - - Ask the given question and return the answer. Also catch - KeyboardInterrupt (Ctrl+C) and EOFError (Ctrl+D) exceptions and - immediately return None if one of those is found. - """ - try: - answer = raw_input(question) - except (KeyboardInterrupt, EOFError): - print - answer = None - - return answer - def show_help(exit_code = 0): """ help() -> None