On 04/10/2015 12:10 AM, Nathan Scott wrote:
> ----- Original Message -----
>> ----- Original Message -----
>>> [...]
>>> I got rid of the utf-8 encoding, and I get the following error (using
>>> "count" as the unit):
>>>
>>> PM_ERR_CONV Impossible value or scale conversion count
>>>
>>> So, there must be a bug still lurking there.
>>>
>>
>> Hmmm. Below the API the code looks like this:
>>
>> @staticmethod
>> def pmParseUnitsStr(string):
>> if type(string) != type('') and type(string) != type(b''):
>> raise pmErr(c_api.PM_ERR_CONV, str(string))
>> if type(string) != type(b''):
>> string = string.encode('utf-8')
>>
>> I'm not sure what you meant by 'using the "count" as unit' above - what's
>> the type of "count"? I guess its failing that check on the first line,
>> which is expecting either unicode or string of bytes.
>
> Tick, tick, tick ... neurons finally fire ... oh, I think I see what you meant
> now - "count", as in the literal string "count", not a variable, heh. However
> I'm still getting good results with that here:
>
> $ python
> Python 2.7.5 (default, Nov 3 2014, 14:26:24)
> [GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from pcp import pmapi
>>>> import cpmapi as c_api
>>>> context = pmapi.pmContext()
>>>> context.pmParseUnitsStr("count")
> (<pcp.pmapi.pmUnits object at 0x7ff718e7c710>, 1.0)
>>>> ^D
>
> $ python3
> Python 3.3.2 (default, Dec 4 2014, 12:49:00)
> [GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from pcp import pmapi
>>>> import cpmapi as c_api
>>>> context = pmapi.pmContext()
>>>> context.pmParseUnitsStr("count")
> (<pcp.pmapi.pmUnits object at 0x7f9e3952fb00>, 1.0)
>>>> ^D
>
>
> I guess one of those fails with an exception for you locally?
Your example works fine:
>>> from pcp import pmapi
>>> context = pmapi.pmContext()
>>> context.pmParseUnitsStr("count")
(<pcp.pmapi.pmUnits object at 0x7f5a105a1710>, 1.0)
But the following fails:
>>> context.pmParseUnitsStr(u'count')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/pcp/pmapi.py", line 1927, in
pmParseUnitsStr
raise pmErr(c_api.PM_ERR_CONV, str(string))
pcp.pmapi.pmErr: PM_ERR_CONV Impossible value or scale conversion count
You weren't passing in a unicode string.
--
David Smith
dsmith@xxxxxxxxxx
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)
|