pcp
[Top] [All Lists]

bug in python pmGetArchiveEnd()

To: pcp@xxxxxxx
Subject: bug in python pmGetArchiveEnd()
From: Jonathan Lim <jlim@xxxxxxx>
Date: Fri, 21 Mar 2014 18:56:02 -0700
Delivered-to: pcp@xxxxxxxxxxx
User-agent: Mutt/1.5.21 (2010-09-15)
I'm getting the following error in pmGetArchiveEnd():

  Traceback (most recent call last):
    ...
    File "/usr/lib64/python2.6/site-packages/pcp.py", line 1391, in 
pmGetArchiveEnd
      status = libpcp.pmGetArchiveEnd ( tvp )
  ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>: expected 
timeval instance instead of LP_timeval

I fixed it as follows, though I'm not sure if it's the right way:

--- pcp.py.O    2014-03-14 01:33:57.000000000 -0500
+++ pcp.py      2014-03-21 20:27:59.000000000 -0500
@@ -645,7 +645,7 @@ libpcp.pmGetArchiveLabel.restype = c_int
 libpcp.pmGetArchiveLabel.argtypes = [ POINTER(pmLogLabel) ]
 
 libpcp.pmGetArchiveEnd.restype = c_int
-libpcp.pmGetArchiveEnd.argtypes = [ timeval ]
+libpcp.pmGetArchiveEnd.argtypes = [ POINTER(timeval) ]
 
 libpcp.pmGetInDomArchive.restype = c_int
 libpcp.pmGetInDomArchive.argtypes = [
@@ -1384,11 +1384,11 @@ class pmContext( object ):
     def pmGetArchiveEnd( self ):
         """PMAPI - Get the last recorded timestamp from the archive
         """
-        tvp = POINTER(timeval)()
+        tvp = timeval()
         status = libpcp.pmUseContext( self.ctx )
         if status < 0:
             raise pmErr, status
-        status = libpcp.pmGetArchiveEnd ( tvp )
+        status = libpcp.pmGetArchiveEnd ( byref(tvp) )
         if status < 0:
             raise pmErr, status
         return status, tvp

Can someone please review?  Thanks.

On a related note, is the loglabel argument to pmGetArchiveLabel()
necessary, given that it's called similar to pmGetArchiveEnd()?

Jonathan Lim

<Prev in Thread] Current Thread [Next in Thread>