1
# Copyright (C) 2008-2011 LottaNZB Development Team
3
# This program 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 3.
7
# This program 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.
12
# You should have received a copy of the GNU General Public License
13
# along with this program; if not, write to the Free Software
14
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
16
from lottanzb.core.environ import _
21
"SessionNotSpecifiedError",
22
"SessionUnknownError",
23
"SessionConnectionError",
24
"SessionNoExecutableError",
25
"SessionNoServerError",
26
"SessionPermissionError",
30
class SessionError(Exception):
33
def __init__(self, session=None, message=""):
34
self.session = session
37
self.message = message
39
Exception.__init__(self)
45
return _("Unknown error in session '%s'.") % self.session.get_name()
47
return _("Unknown error in session.")
50
class SessionStartError(SessionError):
52
prefix = _("Could not start session")
55
prefix = _("Could not start session '%s'") % self.session.get_name()
58
return "%s: %s" % (prefix, self.message)
62
class SessionNotSpecifiedError(SessionStartError):
63
message = _("No session has been selected.")
66
class SessionUnknownError(SessionStartError):
67
message = _("Unknown session type.")
70
class SessionConnectionError(SessionStartError):
71
def __init__(self, session, connection_error, previous_success=False):
72
self.connection_error = connection_error
73
self.previous_success = previous_success
75
SessionStartError.__init__(self, session,
76
str(self.connection_error))
79
class SessionNoExecutableError(SessionStartError):
80
message = _("Could not find the SABnzbd executable.")
83
class SessionNoServerError(SessionStartError):
84
message = _("No news server has been specified.")
87
class SessionPermissionError(SessionStartError):
88
message = _("Not allowed to launch SABnzbd.")
90
def __init__(self, session=None, executable=None):
91
SessionStartError.__init__(self, session)
93
self.executable = executable
96
extra_info = _("%s is probably not executable.") % self.executable
98
self.message = "%s %s" % (self.message, extra_info)
101
class SessionImportError(SessionStartError):
102
def __init__(self, session=None, module=""):
103
SessionStartError.__init__(self, session)
106
self.message= _("Could not find the Python module '%s'.") % self.module