ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/pystatgrab/_statgrab.pyx
(Generate patch)

Comparing projects/pystatgrab/_statgrab.pyx (file contents):
Revision 1.18 by ats, Wed Sep 14 18:15:44 2005 UTC vs.
Revision 1.21 by tdb, Mon Jun 16 21:06:49 2008 UTC

# Line 27 | Line 27 | ctypedef int gid_t
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:
# Line 272 | Line 274 | py_SG_PROCESS_STATE_ZOMBIE = SG_PROCESS_STATE_ZOMBIE
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:
279 <            setattr(self, attr, attrs[attr])
280 <    def __getitem__(self, item):
281 <        return getattr(self, item)
282 <    def __repr__(self):
283 <        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):
290          self.value = value
# Line 291 | Line 294 | class StatgrabException(Exception):
294  
295   def py_sg_init():
296      if sg_init() == 0:
297 +        return True
298 +    else:
299 +        return False
300 +
301 + def py_sg_shutdown():
302 +    if sg_shutdown() == 0:
303 +        return True
304 +    else:
305 +        return False
306 +
307 + def py_sg_snapshot():
308 +    if sg_snapshot() == 0:
309          return True
310      else:
311          return False

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines