def confirm_once(self, question): with self._log_lock: if self._last_log_prefix is not None: self._log_file.write("\n") self._last_log_prefix = None # XXX: This should be DRY! self._log_file.write( ansi_warn("warning: {0} (y/N) ".format(question), outfile=self._log_file)) if self._auto_response is not None: self._log_file.write("{0}\n".format(self._auto_response)) return self._auto_response == "y" response = sys.stdin.readline() if response == "": return False response = response.rstrip().lower() if response == "y": return True if response == "n" or response == "": return False return None
def confirm_once(self, question): with self._log_lock: if self._last_log_prefix is not None: self._log_file.write("\n") self._last_log_prefix = None # XXX: This should be DRY! self._log_file.write(ansi_warn( "warning: {0} (y/N) ".format(question), outfile=self._log_file )) if self._auto_response is not None: self._log_file.write("{0}\n".format(self._auto_response)) return self._auto_response == "y" response = sys.stdin.readline() if response == "": return False response = response.rstrip().lower() if response == "y": return True if response == "n" or response == "": return False return None
def warn(self, msg): self.log(ansi_warn("warning: " + msg, outfile=self._log_file))
def error(self, msg): self.log(ansi_warn("error: " + msg, outfile=self._log_file))