From Juliette.Mcilroy at aesi.com Tue Oct 9 01:26:18 2012 From: Juliette.Mcilroy at aesi.com (Juliette Mcilroy) Date: Mon, 8 Oct 2012 16:26:18 -0700 Subject: [capi-sig] SW Development Engineer in Test/South Bay Area Message-ID: My client top Silicon Valley Client is looking for someone who has hands-on testing experience with Windows API Frameworks in both 32-bit and 64-bit environment plus scripting in Python. The ideal candidate will have the following experience: ? Demonstrated experience and understanding of C Language. This means you have recent experience with C/C++ programming experience specific to Windows environments. The strength of your programming knowledge and skills will be thoroughly examined. ? Demonstrated experience with testing Windows API Frameworks in an enterprise environment. ? Thorough understanding of QA white box Testing methodologies. You can demonstrate your ability to create unique test plans from scratch and execute these test plans with minimal supervision and oversight. ? Demonstrated hands-on experience designing and creating automation scripts for unit testing and above using common scripting languages (Python, Perl, VB); Python is preferable. ? Demonstrated experience in owning testing in a fluid, fast paced environment. You have the exceptional communication skills needed to gather information from multiple stakeholders and suggest reasonable priorities against constantly moving targets. If you're interest is piqued, please shoot me an email with your resume and the best day/time/contact number to reach you & I'll be sure to follow up! Thank You in advance for your time! Juliette McIlroy Lead Technical Recruiter Albin Engineering Services Inc. ph : 408-733-AESI (2374) x18 juliette.mcilroy at aesi.com www.aesi.com From egranata at apple.com Wed Oct 10 20:24:02 2012 From: egranata at apple.com (Enrico Granata) Date: Wed, 10 Oct 2012 11:24:02 -0700 Subject: [capi-sig] Triggering a KeyboardInterrupt in a PyObject_CallObject Message-ID: <5BF122F9-EC04-430F-A45E-A273B72B26F1@apple.com> Hi list. I have a situation where I make a PyObject_CallObject call on one thread, and then I watch for keyboard input on a separate thread. When the user hits CTRL-C, this second thread will see it and needs to make it so that the callable being run on the first thread gets "stopped" with a KeyboardInterrupt exception I tried calling Py_AddPendingCall() on the second thread, and passing it a pointer to a function foo. My first attempt was to make foo call PyErr_SetInterrupt() and PyErr_CheckSignals(). Since this did not work, I rewrote foo to explicitly set the KeyboardInterrupt exception with PyErr_SetString() and returning -1 This worked in the sense that I saw the KeyboardInterrupt come out on screen as a traceback, but it did not stop the function from running. Am I doing something wrong? Is there even a way to raise an exception "inside" a PyObject_CallObject without the callee doing anything? It would be much preferable that the called python object did not have to do anything in order to be interruptible, but I would be willing to compromise on some simple "make me interruptible" pattern, provided it really is simple. Thanks for any help. Enrico Granata ? egranata@?.com ? (408) 972-7683 From x at jwp.io Thu Oct 11 02:01:32 2012 From: x at jwp.io (James William Pye) Date: Wed, 10 Oct 2012 17:01:32 -0700 Subject: [capi-sig] Triggering a KeyboardInterrupt in a PyObject_CallObject In-Reply-To: <5BF122F9-EC04-430F-A45E-A273B72B26F1@apple.com> References: <5BF122F9-EC04-430F-A45E-A273B72B26F1@apple.com> Message-ID: On Oct 10, 2012, at 11:24 AM, Enrico Granata wrote: > Am I doing something wrong? Is there even a way to raise an exception "inside" a PyObject_CallObject without the callee doing anything? > It would be much preferable that the called python object did not have to do anything in order to be interruptible, Maybe this is what you're looking for: http://docs.python.org/c-api/init.html?highlight=async#PyThreadState_SetAsyncExc Tho, I'm not sure if it's a good idea for your particular case? From jendeavor at gmail.com Fri Oct 19 13:36:43 2012 From: jendeavor at gmail.com (endeavor john) Date: Fri, 19 Oct 2012 17:06:43 +0530 Subject: [capi-sig] Equivalent of PyByteArray_FromStringAndSize in python2.4 Message-ID: Hello Team, While cross-compiling XBMC Apllication.The code is generated using Java. I am getting an error :PyByteArray_FromStringAndSize.is undefined, i understand that this api is defined in python2.6. But we are supposed to compile this with python-2.4 libraries. Can you please let us know what is the equivalent API in python 2.4.This is the Code which using the "PyByteArray_FromStringAndSize" API. static PyObject* xbmc_XBMCAddon_xbmc_RenderCapture_getImage(PyObject* self, PyObject *args, PyObject *kwds) { RenderCapture* rc = ((RenderCapture*)retrieveApiInstance((PyObject*)self,&PyXBMCAddon_xbmc_RenderCapture_Type,"getImage","XBMCAddon::xbmc::RenderCapture")); if (rc->GetUserState() != CAPTURESTATE_DONE) { PyErr_SetString(PyExc_SystemError, "illegal user state"); return NULL; } ssize_t size = rc->getWidth() * rc->getHeight() * 4; return PyByteArray_FromStringAndSize((const char *)rc->GetPixels(), size); } Thanks, John From mal at egenix.com Fri Oct 19 15:24:29 2012 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 19 Oct 2012 15:24:29 +0200 Subject: [capi-sig] Equivalent of PyByteArray_FromStringAndSize in python2.4 In-Reply-To: References: Message-ID: <5081548D.3040203@egenix.com> On 19.10.2012 13:36, endeavor john wrote: > Hello Team, > While cross-compiling XBMC Apllication.The code is generated using Java. > I am getting an error :PyByteArray_FromStringAndSize.is undefined, i > understand that this api is defined in python2.6. > But we are supposed to compile this with python-2.4 libraries. > > Can you please let us know what is the equivalent API in python 2.4.This is > the Code which using the "PyByteArray_FromStringAndSize" API. > > static PyObject* xbmc_XBMCAddon_xbmc_RenderCapture_getImage(PyObject* > self, PyObject *args, PyObject *kwds) > { > RenderCapture* rc = > ((RenderCapture*)retrieveApiInstance((PyObject*)self,&PyXBMCAddon_xbmc_RenderCapture_Type,"getImage","XBMCAddon::xbmc::RenderCapture")); > if (rc->GetUserState() != CAPTURESTATE_DONE) > { > PyErr_SetString(PyExc_SystemError, "illegal user state"); > return NULL; > } > > ssize_t size = rc->getWidth() * rc->getHeight() * 4; > return PyByteArray_FromStringAndSize((const char *)rc->GetPixels(), size); > } This depends a bit on what the library expects as input elsewhere and whether the memory area allocation is being managed elsewhere or not. You could use a PyBuffer_FromReadWriteMemory() or a PyString_FromStringAndSize() with Python 2.4. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Oct 19 2012) >>> Python Projects, Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2012-09-27: Released eGenix PyRun 1.1.0 ... http://egenix.com/go35 2012-09-26: Released mxODBC.Connect 2.0.1 ... http://egenix.com/go34 2012-09-25: Released mxODBC 3.2.1 ... http://egenix.com/go33 2012-10-23: Python Meeting Duesseldorf ... 4 days to go eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From epperly2 at llnl.gov Wed Oct 24 23:57:57 2012 From: epperly2 at llnl.gov (Tom Epperly) Date: Wed, 24 Oct 2012 14:57:57 -0700 Subject: [capi-sig] Embedded Python seems broken on Mac OS X Mountain LIon Message-ID: <50886465.50208@llnl.gov> I am trying to work with Apple Mountain Lion's install of Python 2.7. I have a language interoperability tool, Babel http://www.llnl.gov/CASC/components/, that used embedded Python when other languages are calling Python (c.g., C++ calling Python). My fundamental problem is that sys.path is not being initialized the same when I dlopen(libpython2.7.dylib) and initialize Python compared with how the sys.path is set when the Python executable is called directly. This causes Python to fail to load the numpy module used by Babel. bash-3.2$ /usr/bin/python2.7 -c "import sys; print sys.path; import numpy" > /tmp/out1 bash-3.2$ /usr/bin/python -c "import sys; print sys.path; import numpy" > /tmp/out2 bash-3.2$ cat /tmp/out1 ['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages'] bash-3.2$ diff /tmp/out1 /tmp/out2 bash-3.2$ ls -al /usr/bin/python2.7 lrwxr-xr-x 1 root wheel 75 Aug 23 11:10 /usr/bin/python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 Presumably, this C program that uses dlopen(), Py_Initialize, and Py_SimpleString should have exactly the same output. /** foo.c */ #include #include int main(int argc, char **argv) { // void *lptr = dlopen("/System/Library/Frameworks/Python.framework/Python", RTLD_NOW | RTLD_GLOBAL); void *lptr = dlopen("/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib", RTLD_NOW | RTLD_GLOBAL); if (lptr) { void (*pyinit)(void) = dlsym(lptr, "Py_Initialize"); if (pyinit) { int (*runSimple)(const char *); (*pyinit)(); /* initialize Python */ runSimple = dlsym(lptr, "PyRun_SimpleString"); if (runSimple) { (*runSimple)("import sys ; print sys.path; import numpy"); } } else { fprintf(stderr, "Unable to locate Py_Initialize: %s\n", dlerror()); } } else { fprintf(stderr, "Error loading Python shared library: %s\n", dlerror()); } } bash-3.2$ gcc foo.c ; ./a.out ['/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-darwin', '/usr/lib/python2.7/plat-mac', '/usr/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/Extras/lib/python', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload'] Traceback (most recent call last): File "", line 1, in ImportError: No module named numpy However as you see, it has a completely different sys.path. I can't seem to find a way to get it to initialize Python with the same sys.path. It seems like the libpython2.7.dylib is broken. I am at a loss on how to fix this or even who to ask for help. Regards, Tom Epperly From robertsteckroth at gmail.com Sat Oct 27 13:36:35 2012 From: robertsteckroth at gmail.com (Robert Steckroth) Date: Sat, 27 Oct 2012 07:36:35 -0400 Subject: [capi-sig] Universal setter function not in docs? Message-ID: Hello Gang, I am fresh to this list so, hello gang! ======================================== I have the need for a universal setter function to set objects. The documentation suggests that there is a way to use a void pointer to define object data for comparison. Unfortunately, there does not seem to be any examples on how to do this. This snippet only works with the `last` attribute of the object --> static int Noddy_setlast(Noddy *self, PyObject *value, void *closure) { if (value == NULL) { PyErr_SetString(PyExc_TypeError, "Cannot delete the last attribute"); return -1; } if (! PyString_Check(value)) { PyErr_SetString(PyExc_TypeError, "The last attribute value must be a string"); return -1; } Py_DECREF(self->last); Py_INCREF(value); self->last = value; return 0; } Is there any examples of a universal setter function for `PyGetSetDef` that would check a attribute type with the 3 argument in Noddy_setlast? Thank you. *From the docs* [http://docs.python.org/extending/newtypes.html] > `The getter function is passed a Noddy object and a ?closure?, which is void pointer. In this case, the closure is ignored. (The closure supports an advanced usage in which definition data is passed to the getter and setter. This could, for example, be used to allow a single set of getter and setter functions that decide the attribute to get or set based on data in the closure.)` -- Bust0ut, Surgemcgee: Systems Engineer --- surgemcgee.com Django_Teamplate3d From python_capi at behnel.de Sat Oct 27 16:51:26 2012 From: python_capi at behnel.de (Stefan Behnel) Date: Sat, 27 Oct 2012 16:51:26 +0200 Subject: [capi-sig] Universal setter function not in docs? In-Reply-To: References: Message-ID: <508BF4EE.6040406@behnel.de> Robert Steckroth, 27.10.2012 13:36: > Hello Gang, I am fresh to this list so, hello gang! I didn't know I was participating in a Gang. Maybe you meant someone else. > I have the need for a universal setter function to set objects. You are not very clear about what you want to achieve. What's "universal" about that setter function? Could you give an example? Stefan From ideasman42 at gmail.com Sat Oct 27 17:15:19 2012 From: ideasman42 at gmail.com (Campbell Barton) Date: Sun, 28 Oct 2012 02:15:19 +1100 Subject: [capi-sig] Universal setter function not in docs? In-Reply-To: <508BF4EE.6040406@behnel.de> References: <508BF4EE.6040406@behnel.de> Message-ID: For an example of getset using the 3rd argument, sometimes I use this so single get/set functions can be used to access different flags. https://svn.blender.org/svnroot/bf-blender/trunk/blender/source/blender/python/bmesh/bmesh_py_types.c See: bpy_bm_elem_hflag_get / bpy_bm_elem_hflag_set also bpy_bmelemseq_elem_get On Sun, Oct 28, 2012 at 1:51 AM, Stefan Behnel wrote: > Robert Steckroth, 27.10.2012 13:36: > >> Hello Gang, I am fresh to this list so, hello gang! > > > I didn't know I was participating in a Gang. Maybe you meant someone else. > > > >> I have the need for a universal setter function to set objects. > > > You are not very clear about what you want to achieve. What's "universal" > about that setter function? Could you give an example? > > Stefan > > > _______________________________________________ > capi-sig mailing list > capi-sig at python.org > http://mail.python.org/mailman/listinfo/capi-sig -- - Campbell From stefan_ml at behnel.de Sat Oct 27 13:55:31 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 27 Oct 2012 13:55:31 +0200 Subject: [capi-sig] Universal setter function not in docs? In-Reply-To: References: Message-ID: <508BCBB3.5060401@behnel.de> Robert Steckroth, 27.10.2012 13:36: > Hello Gang, I am fresh to this list so, hello gang! I didn't know I was participating in a Gang. Maybe you meant someone else. > I have the need for a universal setter function to set objects. You are not very clear about what you want to achieve. What's "universal" about that setter function? Could you give an example? Stefan From robertsteckroth at gmail.com Sun Oct 28 15:52:21 2012 From: robertsteckroth at gmail.com (Robert Steckroth) Date: Sun, 28 Oct 2012 10:52:21 -0400 Subject: [capi-sig] A little push into the right direction Message-ID: Hello Gang, I am asking that one of you can point me into the correct direction. I have a python module which has two objects with many methods and attributes in each. The two hypothetical objects are "house" and "tree". E.g. Used like below: import my_mod h = my_mod.house() t = my_mod.tree() They also contain attributes like: h.color t.height I would like to pass the t object to a house.attach() method e.g. h.attach(t) and modify the attributes of t within the house object methods. What is the best practice to reference separate objects in a module which are passed in at the interpreter? Any thoughts are appreciated as keywords and ideas are easy to Google. Thank you, Robert. -- Bust0ut, Surgemcgee: Systems Engineer --- surgemcgee.com Django_Teamplate3d From robertsteckroth at gmail.com Sun Oct 28 17:24:12 2012 From: robertsteckroth at gmail.com (Robert Steckroth) Date: Sun, 28 Oct 2012 12:24:12 -0400 Subject: [capi-sig] A little push into the right direction In-Reply-To: References: Message-ID: Alright, disregard this message. This appears to be easy enough with the use structs. Simply posted this in haste, sorry. On Sun, Oct 28, 2012 at 10:52 AM, Robert Steckroth wrote: > Hello Gang, I am asking that one of you can point me into the correct direction. > I have a python module which has two objects with many methods and > attributes in each. > The two hypothetical objects are "house" and "tree". > E.g. Used like below: > import my_mod > h = my_mod.house() > t = my_mod.tree() > > They also contain attributes like: > h.color > t.height > > > I would like to pass the t object to a house.attach() method > e.g. h.attach(t) > and modify the attributes of t within the house object methods. What > is the best practice to reference separate objects in a module > which are passed in at the interpreter? Any thoughts are appreciated > as keywords and ideas > are easy to Google. > > Thank you, Robert. > > > > > > -- > Bust0ut, Surgemcgee: Systems Engineer --- > surgemcgee.com > Django_Teamplate3d -- Bust0ut, Surgemcgee: Systems Engineer --- surgemcgee.com Django_Teamplate3d