2 from fcntl import flock, LOCK_EX, LOCK_SH, LOCK_UN
3 import contextlib as clib
6 class InvirtConfigError(AttributeError):
11 def lock_file(path, exclusive = True):
12 with clib.closing(open(path, 'w')) as f:
28 class InvalidInput(Exception):
29 """Exception for user-provided input is invalid but maybe in good faith.
31 This would include setting memory to negative (which might be a
32 typo) but not setting an invalid boot CD (which requires bypassing
35 def __init__(self, err_field, err_value, expl=None):
36 Exception.__init__(self, expl)
37 self.err_field = err_field
38 self.err_value = err_value
40 class CodeError(Exception):
41 """Exception for internal errors or bad faith input."""