stov_exceptions.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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"
  32. " again!")
  33. def __str__(self):
  34. return self.__message
  35. class SubscriptionNotFoundException(Exception):
  36. """This exception will be raised when a requested subscription can't be
  37. found in the database
  38. """
  39. def __init__(self):
  40. self.__message = _("The subscription you requested could not be "
  41. "found in the database, requested action aborted.")
  42. def __str__(self):
  43. return self.__message
  44. class NoDataFromYoutubeAPIException(Exception):
  45. """This exception will be raised when the Connection to the youtube API
  46. failed or no data was returned
  47. """
  48. def __init__(self):
  49. self.__message = _("The connection to the youtube API failed or "
  50. "no data was returned.")
  51. def __str__(self):
  52. return self.__message
  53. class YoutubeAPITimeoutException(Exception):
  54. """This exception will be raised when an API request times out"""
  55. def __init__(self, title):
  56. self.__message = _("The API Request timed out for subscription %s,"
  57. "please try again later") % title
  58. def __str__(self):
  59. return self.__message
  60. class ConfigFileWriteErrorException(Exception):
  61. """This exception will be raised when a write access to the configuration
  62. file fails.
  63. """
  64. def __init__(self):
  65. self.__message = _("The configuration could not be written, please"
  66. "check that the configuration direcroty exists"
  67. "and is writable.")
  68. def __str__(self):
  69. return self.__message
  70. class DirectoryCreationFailedException(Exception):
  71. """This exception will be raised when the creation of a directory failed.
  72. """
  73. def __init__(self):
  74. self.__message = _("The directory could not be created, "
  75. "please check that the parent directory "
  76. "exists and is writable")
  77. def __str__(self):
  78. return self.__message
  79. class ConfigFileReadErrorException(Exception):
  80. """This exception will be raised when the configuration file couldn't be
  81. opened for reading
  82. """
  83. def __init__(self):
  84. self.__message = _("The configuration could not be read, please check "
  85. "that the configuration file exists and is "
  86. "readable")
  87. def __str__(self):
  88. return self.__message
  89. class InvalidConfigurationVersionException(Exception):
  90. """This exception will be raised when an invalid configuration version
  91. is detected.
  92. """
  93. def __init__(self):
  94. self.__message = _("Invalid config version read.")
  95. def __str__(self):
  96. return self.__message
  97. class SubscriptionDisabledException(Exception):
  98. """This exception will be raised when an exception is disabled and
  99. a requested action is not taken because of this fact.
  100. """
  101. def __init__(self, subscription):
  102. self.__message = _("The subscription %s is disabled, videos will"
  103. "not be downloaded.") % subscription
  104. def __str__(self):
  105. return self.__message
  106. class DownloadDirectoryCreationFailedException(Exception):
  107. """This exception will be raised when the creation of a subscription
  108. directory to download a video failed.
  109. """
  110. def __init__(self):
  111. self.__message = _("Download directory does not exist and can't be "
  112. "created. Please check your configuration and try "
  113. "again")
  114. def __str__(self):
  115. return self.__message