1 """Exceptions for the web interface."""
3 from sipb_xen_database import Machine
5 class MyException(Exception):
6 """Base class for my exceptions"""
9 class InvalidInput(MyException):
10 """Exception for user-provided input is invalid but maybe in good faith.
12 This would include setting memory to negative (which might be a
13 typo) but not setting an invalid boot CD (which requires bypassing
16 def __init__(self, err_field, err_value, expl=None):
17 MyException.__init__(self, expl)
18 self.err_field = err_field
19 self.err_value = err_value
21 class CodeError(MyException):
22 """Exception for internal errors or bad faith input."""
28 """Global state of the system, to avoid duplicate remctls to get state"""
29 def __init__(self, user):
32 def __get_uptimes(self):
33 if not hasattr(self, '_uptimes'):
34 self._uptimes = controls.getUptimes(Machine.select())
36 uptimes = property(__get_uptimes)
39 """Clear the state so future accesses reload it."""
40 for attr in ('_uptimes', ):
41 if hasattr(self, attr):