Vincent | 20 May 22:12
Favicon

Question on Bridging/Integration

Hi there,

I'm new the whole PyObjC thing and have a simple document-bases app for which my goal is to all the user
(personal project, so actually just me :P) to provide his/her (my) own filtering logic on a per-document basis.

I basically have an NSSet of objects which need to be filtered based on a user-provided logic.
As the logic should not be limited to rather primitive NSPredicates I'd like to provide a barebones in-app
Python editor in which the user can define his/her logic.

>From what I've found on the web so far I know that one can subclass one's own Objective-C classes from inside
Python using "objc.lookUpClass(…)".
There is however still one question that remained unanswered:
Being able to instantiate an Objective-C object from Python is neat, but still isolated. How do I expose a
particular object instance from one language to the other?
After all I need to pass my Objective-C object to Python for evaluation and receive an answer from it in
respose. 

A minimal sample function (as provided by the user at runtime) would look something like this:

def shallRejectObject(object)
	if object.foo():
		return True
	return False

Being totally new to PyObjC I'm thinking of some kind of reverse "objc.lookUpClass(…)" to allow me to
instantiate my Python subclass from within Objective-C. Or how else would one approach this?

Any hints?

Thanks in advance,
(Continue reading)

Nicholas Cole | 16 Apr 18:44
Picon

Re: Garbage collection in Python/Pyobjc

On Mon, Apr 16, 2012 at 2:10 PM,  <ronaldoussoren <at> me.com> wrote:
> The autorelease pool does not have to be named pool.
>
> Cocoa has an internal protocol for finding the current autorelease pool, the
> page below contains an explanation on how this could be implemented:
>
>
>  http://www.mikeash.com/pyblog/friday-qa-2011-09-02-lets-build-nsautoreleasepool.html
>
> That's not the real implementation though, the real implementation is closed
> source and probably contains a number of tricks improve the speed.
>

Thanks for a really useful link.

N.

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
Joel Norvell | 10 Apr 09:43
Picon
Favicon

Is there an Xcode Cocoa sample that calls Python?

Hi PyObjC People,

I'm interested in calling Python routines from within a Cocoa/ObjC program.

Is there a sample Xcode project that does this?

I did see Bill Bumgarner's "Calling Python from Objective-C" example and it's helpful. But I'm hoping for a Cocoa sample in an Xcode context to work from if one is available.

I realize that this isn't purely a PyObjC question but I thought this list would be a good place to ask it on.

Sincerely,
Joel

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Pyobjc-dev mailing list
Pyobjc-dev <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
Peter Bernheim | 2 Jan 21:14
Favicon

Garbage collection in Python/Pyobjc

I'm working on a script to convert each page of a large directory of pdfs to jpgs, using a version of this script:
http://files.macscripter.net/joy/files/pdflib.py

I am walking through a directory in Python, and calling the below function on each file. It seems that there
is no garbage collection being performed on any of the objects being created below, and my searches
through the docs don't seem to show an explicit way of performing garbage collection on these rather large
objects. How to ensure that the below code, if called thousands of times within a Python loop isn't going to
consume the entire system's memory?

def pdf2jpgs(pdfpath, pages_dir, resolution=72):
    """I am converting all pages of a PDF file to JPG images."""

    pdfdata = NSData.dataWithContentsOfFile_(pdfpath)
    pdfrep = NSPDFImageRep.imageRepWithData_(pdfdata)
    pagecount = pdfrep.pageCount()
    for i in range(0, pagecount):
        pdfrep.setCurrentPage_(i)
        pdfimage = NSImage.alloc().init()
        pdfimage.addRepresentation_(pdfrep)
        origsize = pdfimage.size()
        width, height = origsize
        pdfimage.setScalesWhenResized_(YES)
        rf = resolution / 72.0
        pdfimage.setSize_((width*rf, height*rf))

        tiffimg = pdfimage.TIFFRepresentation()
        bmpimg = NSBitmapImageRep.imageRepWithData_(tiffimg)
        data = bmpimg.representationUsingType_properties_(NSJPEGFileType, {NSImageCompressionFactor: 1.0})
        pagenum = i + 1
        jpgpath = "%s/pg%d.jpg" % (pages_dir, pagenum)
        if not os.path.exists(jpgpath):
            data.writeToFile_atomically_(jpgpath, False)
    return ''
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
Marc Van Olmen | 27 Dec 22:08
Picon

Getting a better stack trace with PyObjc possible?

hi,


I looked around the web and more specific stack overflow: I was hoping if there is something I can do to have a better stack trace from pyobjc/python.

For example my end users send me this, after a hard crash.

0 libobjc.A.dylib 0x99b51c22 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 350 1 com.apple.CoreFoundation 0x97b2c515 _CFAutoreleasePoolPop + 53 2 com.apple.Foundation 0x96316b87 -[NSAutoreleasePool release] + 131 3 com.apple.CoreFoundation 0x97b01749 CFRelease + 169 4 _objc.so 0x04019c21 object_dealloc + 257 5 org.python.python 0x01c6e2cf subtype_dealloc + 575 6 org.python.python 0x01c3a041 frame_dealloc + 385 7 org.python.python 0x01ced87c tb_dealloc + 156 8 org.python.python 0x01ced88c tb_dealloc + 172 9 org.python.python 0x01c52179 PyDict_DelItem + 249 10 org.python.python 0x01c52251 PyDict_DelItemString + 49 11 org.python.python 0x01cb940a PyEval_EvalFrameEx + 4810 12 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 13 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 14 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 15 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 16 org.python.python 0x01cbee9d PyEval_EvalCodeEx + 2109 17 org.python.python 0x01c3ba36 function_call + 166 18 org.python.python 0x01c0a315 PyObject_Call + 85 19 org.python.python 0x01c1c8e6 instancemethod_call + 422 20 org.python.python 0x01c0a315 PyObject_Call + 85 21 org.python.python 0x01cb717e PyEval_CallObjectWithKeywords + 78 22 org.python.python 0x01cf89d6 t_bootstrap + 70 23 libsystem_c.dylib 0x957c2ed9 _pthread_start + 335 24 libsystem_c.dylib 0x957c66de thread_start + 34
Would be nice to know which method and object was called at 

PyEval_EvalFrameEx + 21862

for example.

Marc
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Pyobjc-dev mailing list
Pyobjc-dev <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
Trevor Bentley | 7 Dec 23:54
Picon
Gravatar

PyObjC and multiprocessing module

I found a bunch of hits for this on Google, but no answers:


I am working on a Python application that uses the multiprocessing library.  I am trying to spawn a process and perform text-to-speech with pyttsx, but I get the dreaded  __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__()  error.

Is there any way to get this working, short of switching back to threads?  I see that the 'correct' way is to fork() and exec(), but I don't see any way to make that compatible with the multiprocessing module's API.

Thanks,

-Trevor

------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Pyobjc-dev mailing list
Pyobjc-dev <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
Marc Van Olmen | 22 Nov 18:37
Picon

Lion and pyobjc 2.2b3 Decimal compares with NSDecimalNumber compare goes in endless recursive call..

hi,


for our project we haven't upgraded to latest version of pyobjc I just notice we run with 2.2b3 but we have the following bug on Lion Only:

When bindings try to compare a decimal number that originally came from Python code. It goes in endless recursive calls...

.... (this last few lines are repeated over and over again...

#3515 0x02edf84d in _ffi_call_SYSV at x86-darwin.S:74
#3516 0x02edfc01 in ffi_call
#3517 0x02ef8d79 in PyObjCFFI_Caller
#3518 0x02f1ddbd in objcsel_call
#3519 0x0289f315 in PyObject_Call
#3520 0x02950677 in PyEval_EvalFrameEx
#3521 0x02953e9d in PyEval_EvalCodeEx
#3522 0x028d0a36 in function_call
#3523 0x0289f315 in PyObject_Call
#3524 0x028b18e6 in instancemethod_call
#3525 0x0289f315 in PyObject_Call
#3526 0x0290706b in half_richcompare
#3527 0x0290714b in slot_tp_richcompare
#3528 0x028e8dd7 in try_rich_compare
#3529 0x028eb60e in PyObject_Compare
#3530 0x02f11f14 in -[OC_PythonNumber compare:]
#3531 0x94ea8f68 in -[NSDecimalNumber compare:]
#3532 0x94f0dc7c in -[NSDecimalNumber isEqual:]
#3533 0x02edf84d in _ffi_call_SYSV at x86-darwin.S:74
#3534 0x02edfc01 in ffi_call
#3535 0x02ef8d79 in PyObjCFFI_Caller
#3536 0x02f1ddbd in objcsel_call
#3537 0x0289f315 in PyObject_Call
#3538 0x02950677 in PyEval_EvalFrameEx
#3539 0x02953e9d in PyEval_EvalCodeEx
#3540 0x028d0a36 in function_call
#3541 0x0289f315 in PyObject_Call
#3542 0x028b18e6 in instancemethod_call
#3543 0x0289f315 in PyObject_Call
#3544 0x0290706b in half_richcompare
#3545 0x0290714b in slot_tp_richcompare
#3546 0x028e8dd7 in try_rich_compare
#3547 0x028eb60e in PyObject_Compare
#3548 0x02f11f14 in -[OC_PythonNumber compare:]
#3549 0x94ea8f68 in -[NSDecimalNumber compare:]
#3550 0x94f0dc7c in -[NSDecimalNumber isEqual:]
#3551 0x02edf84d in _ffi_call_SYSV at x86-darwin.S:74
#3552 0x02edfc01 in ffi_call
#3553 0x02ef8d79 in PyObjCFFI_Caller
#3554 0x02f1ddbd in objcsel_call
#3555 0x0289f315 in PyObject_Call
#3556 0x02950677 in PyEval_EvalFrameEx
#3557 0x02953e9d in PyEval_EvalCodeEx
#3558 0x028d0a36 in function_call
#3559 0x0289f315 in PyObject_Call
#3560 0x028b18e6 in instancemethod_call
#3561 0x0289f315 in PyObject_Call
#3562 0x0290706b in half_richcompare
#3563 0x0290714b in slot_tp_richcompare
#3564 0x028e8dd7 in try_rich_compare
#3565 0x028eb60e in PyObject_Compare
#3566 0x02f11f14 in -[OC_PythonNumber compare:]
#3567 0x94ea8f68 in -[NSDecimalNumber compare:]
#3568 0x94f0dc7c in -[NSDecimalNumber isEqual:]
#3569 0x02edf84d in _ffi_call_SYSV at x86-darwin.S:74
#3570 0x02edfc01 in ffi_call
#3571 0x02ef8d79 in PyObjCFFI_Caller
#3572 0x02f1ddbd in objcsel_call
#3573 0x0289f315 in PyObject_Call
#3574 0x02950677 in PyEval_EvalFrameEx
#3575 0x02953e9d in PyEval_EvalCodeEx
#3576 0x028d0a36 in function_call
#3577 0x0289f315 in PyObject_Call
#3578 0x028b18e6 in instancemethod_call
#3579 0x0289f315 in PyObject_Call
#3580 0x0290706b in half_richcompare
#3581 0x0290714b in slot_tp_richcompare
#3582 0x028e8dd7 in try_rich_compare
#3583 0x028eb60e in PyObject_Compare
#3584 0x02f11f14 in -[OC_PythonNumber compare:]
#3585 0x94ea8f68 in -[NSDecimalNumber compare:]
#3586 0x94f0dc7c in -[NSDecimalNumber isEqual:]
#3587 0x98cc98cd in _NSValuesAreEqual
#3588 0x993a6ccb in -[NSValueBinder _validateDisplayValue]
#3589 0x993a5471 in -[NSValueBinder validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled:]
#3590 0x993ea198 in -[_NSBindingAdaptor _validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled:bindingAdaptor:]
#3591 0x993ea2bf in -[_NSBindingAdaptor validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled:]
#3592 0x992f343e in -[NSTextField textShouldEndEditing:]

Was this bug addressed already in subsequently releases? 

Thanks

Marc Van Olmen

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Pyobjc-dev mailing list
Pyobjc-dev <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
Robert Klep | 21 Nov 07:08
Picon

strange problem using NSWorkspace/NSTask to start PyObjC apps

Hey all,

I'm running into a strange problem with PyObjC-based apps.

The situation: I'm working on a .mailbundle (a plug-in for Apple Mail). From that plug-in, I want to start a
PyObjC-based application. No matter what, this fails: the application gets a SIGSEGV (I'll post some
more information below).

I've used pretty much all methods of starting the application (NSWorkspace, NSTask, even executing "open
-a APP" from the Python subprocess module), and it keeps failing. Of course, the app works without
problems when started manually. Starting the app from a Python-shell using [NSWorkspace
launchApplication:] works, too. Just not from within the plug-in.

Even the simplest 'app' fails:
-snip-
from Foundation import *

class MyTestClass(NSObject): pass
-snip-

Same thing: SIGSEGV.

Starting other apps (like Safari) isn't a problem, so it doesn't seem to be some sandbox-type blocking.

Below is the relevant part of the crashlog. All I've been able to find out is that objc_msgSend_vtable3 is an
Objective-C runtime shortcut for getting 'self'. It smells like a memory issue, but I'd be grateful if
anyone could help me out.

-snip-
Process:         App1 [797]
Path:            /Users/USER/*/App1.app/Contents/MacOS/App1
Identifier:      name.klep.app1
Version:         0.0.0 (0.0.0)
Code Type:       X86-64 (Native)
Parent Process:  launchd [301]

Date/Time:       2011-11-21 06:49:06.394 +0100
OS Version:      Mac OS X 10.7.2 (11C74)
Report Version:  9

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00007fc2dac50c60

VM Regions Near 0x7fc2dac50c60:
    MALLOC_TINY            0000000104e00000-0000000104f00000 [ 1024K] rw-/rwx SM=PRV  
--> 
    STACK GUARD            00007fff5bc00000-00007fff5f400000 [ 56.0M] ---/rwx SM=NUL  stack guard for thread 0

Application Specific Information:
objc_msgSend() selector name: self
objc[797]: garbage collection is OFF

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                 0x00007fff8c84c0cd objc_msgSend_vtable3 + 13
1   _objc.so                        0x0000000101ba5a71 pythonify_c_value + 573
2   _objc.so                        0x0000000101b9d92e 0x101b80000 + 121134
3   org.python.python               0x0000000101a87b58 PyEval_EvalFrameEx + 13318
4   org.python.python               0x0000000101a8acd8 PyEval_EvalCodeEx + 1996
5   org.python.python               0x0000000101a8ae6c PyEval_EvalCode + 341
6   org.python.python               0x0000000101a87e0a PyEval_EvalFrameEx + 14008
7   org.python.python               0x0000000101a8acd8 PyEval_EvalCodeEx + 1996
8   org.python.python               0x0000000101a28abf PyClassMethod_New + 1378
9   org.python.python               0x0000000101a07d32 PyObject_Call + 97
10  org.python.python               0x0000000101a83c40 PyEval_CallObjectWithKeywords + 180
11  _objc.so                        0x0000000101ba0bd3 0x101b80000 + 134099
12  org.python.python               0x0000000101a4cafa PyType_Modified + 891
13  org.python.python               0x0000000101a07d32 PyObject_Call + 97
14  org.python.python               0x0000000101a07eed PyObject_CallFunctionObjArgs + 178
15  org.python.python               0x0000000101a8576b PyEval_EvalFrameEx + 4121
16  org.python.python               0x0000000101a8acd8 PyEval_EvalCodeEx + 1996
17  org.python.python               0x0000000101a8ad4d PyEval_EvalCode + 54
18  org.python.python               0x0000000101aa208f Py_CompileString + 62
19  org.python.python               0x0000000101aa214f PyRun_FileExFlags + 157
20  org.python.python               0x0000000101a801f6 _PyBuiltin_Init + 4630
21  org.python.python               0x0000000101a87d77 PyEval_EvalFrameEx + 13861
22  org.python.python               0x0000000101a8acd8 PyEval_EvalCodeEx + 1996
23  org.python.python               0x0000000101a8ae6c PyEval_EvalCode + 341
24  org.python.python               0x0000000101a87e0a PyEval_EvalFrameEx + 14008
25  org.python.python               0x0000000101a8acd8 PyEval_EvalCodeEx + 1996
26  org.python.python               0x0000000101a8ad4d PyEval_EvalCode + 54
27  org.python.python               0x0000000101aa208f Py_CompileString + 62
28  org.python.python               0x0000000101aa214f PyRun_FileExFlags + 157
29  org.python.python               0x0000000101aa32a2 PyRun_SimpleFileExFlags + 392
30  name.klep.app1                  0x0000000100004476 start + 12854
31  name.klep.app1                  0x0000000100004a96 main + 1465
32  name.klep.app1                  0x0000000100001274 start + 52
-snip-

-- robert

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
Jair Gaxiola | 12 Nov 01:57
Picon
Gravatar

What version of Xcode for lion?

Hi,


I just installed and Lion in Snow Leopard xoode pyobjc runs in 4.1,which version should install Xcode?

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Pyobjc-dev mailing list
Pyobjc-dev <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
Lee Treveil | 11 Nov 01:52
Picon
Gravatar

QuickLook.framework

Are there going to be any bindings implemented for this framework?


Thanks
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Pyobjc-dev mailing list
Pyobjc-dev <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
Gordon Watson | 28 Aug 17:31
Picon

PyObjC on Lion

Hi,


Short version: Does there exsit a working version of PyObcC and AddressBook for Lion?

Long version: ...

I have been using the AddressBook 2.3 wrapper with Python 2.6.6, PyObjC v2.3 (all built using MacPorts) on OS X 10.6 Snow Leopard. After upgrading to OS X 10.7.1 Lion, although most of AddressBook seems to continue working, it no longer reads the postal address fields.

So, I tried reinstalling a fresh version (using MacPorts): Python 2.7.2, PyObjC v2.3 and AddressBook 2.3

I have tried Ronald Oussoren's latest work on bitbucket, but I haven't been able to figure out how to install it.

Thanks so much for any help.

Gordon
------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Pyobjc-dev mailing list
Pyobjc-dev <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev

Gmane