2 General PyAFS utilities, such as error handling
7 # otherwise certain headers are unhappy
8 cdef import from "netinet/in.h": pass
9 cdef import from "afs/vice.h": pass
13 # pioctl convenience wrappers
15 cdef extern int pioctl_read(char *dir, afs_int32 op, void *buffer, unsigned short size, afs_int32 follow) except -1:
21 code = pioctl(dir, op, &blob, follow)
22 # This might work with the rest of OpenAFS, but I'm not convinced
23 # the rest of it is consistent
25 raise OSError(errno, strerror(errno))
31 class AFSException(Exception):
32 def __init__(self, errno):
34 self.strerror = afs_error_message(errno)
37 return "AFSException(%s)" % (self.errno)
40 return "[%s] %s" % (self.errno, self.strerror)
42 def pyafs_error(code):
44 initialize_ACFG_error_table()
45 initialize_KTC_error_table()
46 initialize_PT_error_table()
47 initialize_RXK_error_table()
48 initialize_U_error_table()
53 raise AFSException(code)