| To: | Tom Yearke <tyearke@xxxxxxxxxxx>, pcp@xxxxxxxxxxx |
|---|---|
| Subject: | Re: [pcp] Patch for Python's pmExtractValue Function |
| From: | Stan Cox <scox@xxxxxxxxxx> |
| Date: | Tue, 08 Apr 2014 17:34:57 -0400 |
| Delivered-to: | pcp@xxxxxxxxxxx |
| In-reply-to: | <53342449.7070602@xxxxxxxxxxx> |
| References: | <53342449.7070602@xxxxxxxxxxx> |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 |
I am not absolutely certain about the Python 2.6+ availability
requirement so I think this will do things in a similar 2.5 supported
way. Does this work for you?
diff --git a/src/python/pcp/pmapi.py b/src/python/pcp/pmapi.py
index 3324187..5d37217 100644
--- a/src/python/pcp/pmapi.py
+++ b/src/python/pcp/pmapi.py
@@ -1622,6 +1622,15 @@ class pmContext(object):
byref(outAtom), outtype)
if status < 0:
raise pmErr, status
+
+ if outtype == c_api.PM_TYPE_STRING:
+ # Get address of C string
+ c_str = outAtom.vp
+ # Convert to a python string and have result point to it
+ python_char_array = ctypes.string_at(c_str)
+ outAtom.cp = cast(python_char_array, c_char_p)
+ # Free the C string
+ LIBC.free(c_str)
return outAtom
@staticmethod
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: pcp updates - slow start PMDAs, Ken McDonell |
|---|---|
| Next by Date: | Re: [pcp] pcp updates - Frank's pmmgr exec fix, Ken McDonell |
| Previous by Thread: | pcp updates - minor, Ken McDonell |
| Next by Thread: | Re: [pcp] Patch for Python's pmExtractValue Function, Nathan Scott |
| Indexes: | [Date] [Thread] [Top] [All Lists] |