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: |
297 |
|
else: |
298 |
|
return False |
299 |
|
|
300 |
+ |
def py_sg_shutdown(): |
301 |
+ |
if sg_shutdown() == 0: |
302 |
+ |
return True |
303 |
+ |
else: |
304 |
+ |
return False |
305 |
+ |
|
306 |
+ |
def py_sg_snapshot(): |
307 |
+ |
if sg_snapshot() == 0: |
308 |
+ |
return True |
309 |
+ |
else: |
310 |
+ |
return False |
311 |
+ |
|
312 |
|
def py_sg_drop_privileges(): |
313 |
|
if sg_drop_privileges() == 0: |
314 |
|
return True |
611 |
|
raise StatgrabException, 'sg_get_process_stats() returned NULL' |
612 |
|
list = [] |
613 |
|
for i from 0 <= i < entries: |
614 |
< |
if s.process_name == NULL: |
615 |
< |
s.process_name = '' |
616 |
< |
if s.proctitle == NULL: |
617 |
< |
s.proctitle = '' |
614 |
> |
if s.process_name is NULL: |
615 |
> |
process_name = '' |
616 |
> |
else: |
617 |
> |
process_name = s.process_name |
618 |
> |
if s.proctitle is NULL: |
619 |
> |
proctitle = '' |
620 |
> |
else: |
621 |
> |
proctitle = s.proctitle |
622 |
|
list.append(Result( |
623 |
< |
{'process_name': s.process_name, |
624 |
< |
'proctitle' : s.proctitle, |
623 |
> |
{'process_name': process_name, |
624 |
> |
'proctitle' : proctitle, |
625 |
|
'pid' : s.pid, |
626 |
|
'parent' : s.parent, |
627 |
|
'pgid' : s.pgid, |