| 27 |
|
|
| 28 |
|
cdef extern from "statgrab.h": |
| 29 |
|
cdef extern int sg_init() |
| 30 |
+ |
cdef extern int sg_shutdown() |
| 31 |
+ |
cdef extern int sg_snapshot() |
| 32 |
|
cdef extern int sg_drop_privileges() |
| 33 |
|
|
| 34 |
|
ctypedef enum sg_error: |
| 274 |
|
py_SG_PROCESS_STATE_UNKNOWN = SG_PROCESS_STATE_UNKNOWN |
| 275 |
|
|
| 276 |
|
|
| 277 |
< |
class Result: |
| 277 |
> |
class Result(dict): |
| 278 |
|
def __init__(self, attrs): |
| 279 |
< |
self.attrs = attrs |
| 280 |
< |
for attr in attrs: |
| 281 |
< |
setattr(self, attr, attrs[attr]) |
| 282 |
< |
def __getitem__(self, item): |
| 283 |
< |
return getattr(self, item) |
| 284 |
< |
def __repr__(self): |
| 285 |
< |
return str(self.attrs) |
| 279 |
> |
self.attrs = attrs # to maintain compatibility |
| 280 |
> |
super(Result, self).__init__(attrs) |
| 281 |
> |
|
| 282 |
> |
def __getattr__(self, item): |
| 283 |
> |
try: |
| 284 |
> |
return self.__getitem__(item) |
| 285 |
> |
except KeyError: |
| 286 |
> |
raise AttributeError(item) |
| 287 |
|
|
| 288 |
|
class StatgrabException(Exception): |
| 289 |
|
def __init__(self, value): |