1
0

stov_exceptions.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. # This file is part of stov, written by Helmut Pozimski 2012-2015.
  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. class DBConnectionFailedException(Exception):
  16. """ This exception will be raised when the initial connetion attempt
  17. to the database fails.
  18. """
  19. def __init__(self):
  20. self.__message = _("Could not access the database, please check path"
  21. " and permissions and try again!")
  22. def __str__(self):
  23. return self.__message
  24. class DBWriteAccessFailedException(Exception):
  25. """This exception will be raised when a write access to the database fails
  26. (e.g. when the database file permissions are set to read only).
  27. """
  28. def __init__(self):
  29. self.__message = _("Write access to the database failed, please check "
  30. "file permissions and the file system and try"
  31. " 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 "
  40. "found in 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 "
  75. "exists and is 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 "
  85. "readable.")
  86. def __str__(self):
  87. return self.__message
  88. class InvalidConfigurationVersionException(Exception):
  89. """This exception will be raised when an invalid configuration version
  90. is detected.
  91. """
  92. def __init__(self):
  93. self.__message = _("Invalid config version read.")
  94. def __str__(self):
  95. return self.__message
  96. class SubscriptionDisabledException(Exception):
  97. """This exception will be raised when an exception is disabled and
  98. a requested action is not taken because of this fact.
  99. """
  100. def __init__(self, subscription):
  101. self.__message = _("The subscription %s is disabled, videos will"
  102. " not be downloaded.") % subscription
  103. def __str__(self):
  104. return self.__message
  105. class DownloadDirectoryCreationFailedException(Exception):
  106. """This exception will be raised when the creation of a subscription
  107. directory to download a video failed.
  108. """
  109. def __init__(self):
  110. self.__message = _("The download directory does not exist and can't "
  111. "be created. Please check your configuration and "
  112. "try again.")
  113. def __str__(self):
  114. return self.__message
  115. class ConfigurationMigrationFailed(Exception):
  116. """This exception will be raised when the migration of the configuration
  117. to the json format fails.
  118. """
  119. def __init__(self):
  120. self._message = _("The migration of the configuration to the json "
  121. "format failed.")
  122. def __str__(self):
  123. return self._message
  124. class YoutubeDlCallFailed(Exception):
  125. """This exception will be raised when a call to youtube-dl fails because
  126. of an error returned by youtube-dl.
  127. """
  128. def __init__(self):
  129. self._message = _("Execution of youtube-dl failed.")
  130. def __str__(self):
  131. return self._message