pcp
[Top] [All Lists]

Re: [pcp] bug in python pmGetArchiveEnd()

To: Jonathan Lim <jlim@xxxxxxx>
Subject: Re: [pcp] bug in python pmGetArchiveEnd()
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Sun, 23 Mar 2014 19:09:44 -0400 (EDT)
Cc: PCP Mailing List <pcp@xxxxxxxxxxx>
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <328821978.4187531.1395615936648.JavaMail.zimbra@xxxxxxxxxx>
References: <20140322015602.GA21741@xxxxxxxxxxxxxxxxxxxxx> <328821978.4187531.1395615936648.JavaMail.zimbra@xxxxxxxxxx>
Reply-to: Nathan Scott <nathans@xxxxxxxxxx>
Thread-index: dz3g/557yI78141+2UJMO3tnnapzQv1rzVDG
Thread-topic: bug in python pmGetArchiveEnd()
[Resending with list address fixed]

----- Original Message -----
> Hi Jonathan,
> 
> ----- Original Message -----
> > 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:
> 
> Yep, that looks good.  We'll need to extend the testsuite coverage
> as it appears this API is missing (see qa/src/test_pcp.python, and
> qa/707, and the attached path).  The codebase you're using doesn't
> appear to match what I have here though...
> 
> > --- 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.
> > 
> 
> So in the current version of PCP (and for quite some time IIRC -
> Stan will know for sure though), the error handling in the python
> API makes use of exceptions rather than this kind of status/value
> tuple.
> 
> > On a related note, is the loglabel argument to pmGetArchiveLabel()
> > necessary, given that it's called similar to pmGetArchiveEnd()?
> 
> I think the answer to that question is different on the code you
> are using versus current PCP.
> 
> Can you make use of the code from  git://oss.sgi.com/pcp/pcp  and
> resend your patch against that?  (other than that your patch looks
> fine to be merged, along with the QA patch I've attached).
> 
> cheers.
> 
> --
> Nathan
> 

Attachment: pmapi-py-qa.patch
Description: Text Data

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