callback.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #============================================================================
  2. # This file is part of Pwman3.
  3. #
  4. # Pwman3 is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License, version 2
  6. # as published by the Free Software Foundation;
  7. #
  8. # Pwman3 is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with Pwman3; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. #============================================================================
  17. # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
  18. #============================================================================
  19. """Callback interface
  20. To be used when UI needs to be back to get info from user.
  21. """
  22. class Callback:
  23. """Callback interface. Callback classes must implement this."""
  24. def getinput(self, question):
  25. """Return text"""
  26. pass
  27. def getsecret(self, question):
  28. """Return key"""
  29. pass
  30. def error(self, error):
  31. """Present error to user"""
  32. pass
  33. def warning(self, warning):
  34. """Present warning to user"""
  35. pass
  36. def notice(self, warning):
  37. """Present notice to user"""
  38. pass
  39. class CallbackCancelException(Exception):
  40. def __init__(self, message):
  41. self.message = message
  42. def __str__(self):
  43. return "CallbackCancelException: %s" % (self.message)