stov_exceptions.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # This file is part of stov, written by Helmut Pozimski in 2014.
  2. #
  3. # stov is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, version 2 of the License.
  6. #
  7. # stov is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with stov. If not, see <http://www.gnu.org/licenses/>.
  14. # -*- coding: utf8 -*-
  15. from __future__ import unicode_literals
  16. class DBConnectionFailedException(Exception):
  17. """ This exception will be raised when the initial connetion attempt
  18. to the database fails.
  19. """
  20. def __init__(self):
  21. self.__message = _("Could not access the database, please check path"
  22. " and permissions and try again!")
  23. def __str__(self):
  24. return self.__message
  25. class DBWriteAccessFailedException(Exception):
  26. """This exception will be raised when a write access to the database fails
  27. (e.g. when the database file permissions are set to read only).
  28. """
  29. def __init__(self):
  30. self.__message = _("Write access to the database failed, please check"
  31. "file permissions and the file system and try again!")
  32. def __str__(self):
  33. return self.__message
  34. class SubscriptionNotFoundException(Exception):
  35. """This exception will be raised when a requested subscription can't be
  36. found in the database
  37. """
  38. def __init__(self):
  39. self.__message = _("The subscription you requested could not be found in "
  40. "the database, requested action aborted.")
  41. def __str__(self):
  42. return self.__message
  43. class NoDataFromYoutubeAPIException(Exception):
  44. """This exception will be raised when the Connection to the youtube API
  45. failed or no data was returned
  46. """
  47. def __init__(self):
  48. self.__message = _("The connection to the youtube API failed or "
  49. "no data was returned.")
  50. def __str__(self):
  51. return self.__message
  52. class YoutubeAPITimeoutException(Exception):
  53. """This exception will be raised when an API request times out"""
  54. def __init__(self, title):
  55. self.__message = _("The API Request timed out for subscription %s,"
  56. "please try again later") % title
  57. def __str__(self):
  58. return self.__message
  59. class ConfigFileWriteErrorException(Exception):
  60. """This exception will be raised when a write access to the configuration
  61. file fails.
  62. """
  63. def __init__(self):
  64. self.__message = _("The configuration could not be written, please"
  65. "check that the configuration direcroty exists"
  66. "and is writable.")
  67. def __str__(self):
  68. return self.__message
  69. class DirectoryCreationFailedException(Exception):
  70. """This exception will be raised when the creation of a directory failed.
  71. """
  72. def __init__(self):
  73. self.__message = _(_("The directory could not be created, "
  74. "please check that the parent directory exists and is"
  75. " writable"))
  76. def __str__(self):
  77. return self.__message
  78. class ConfigFileReadErrorException(Exception):
  79. """This exception will be raised when the configuration file couldn't be
  80. opened for reading
  81. """
  82. def __init__(self):
  83. self.__message = _("The configuration could not be read, please check "
  84. "that the configuration file exists and is readable")
  85. def __str__(self):
  86. return self.__message
  87. class InvalidConfigurationVersionException(Exception):
  88. """This exception will be raised when an invalid configuration version
  89. is detected.
  90. """
  91. def __init__(self):
  92. self.__message = _("Invalid config version read.")
  93. def __str__(self):
  94. return self.__message
  95. class SubscriptionDisabledException(Exception):
  96. """This exception will be raised when an exception is disabled and
  97. a requested action is not taken because of this fact.
  98. """
  99. def __init__(self, subscription):
  100. self.__message = _("The subscription %s is disabled, videos will"
  101. "not be downloaded.") % subscription
  102. def __str__(self):
  103. return self.__message
  104. class DownloadDirectoryCreationFailedException(Exception):
  105. """This exception will be raised when the creation of a subscription
  106. directory to download a video failed.
  107. """
  108. def __init__(self):
  109. self.__message = _("Download directory does not exist and can't be "
  110. "created. Please check your configuration and try again")
  111. def __str__(self):
  112. return self.__message