pyobjc-dev Mailing List for PyObjC (Page 73)
Brought to you by:
ronaldoussoren
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(9) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(1) |
Feb
(2) |
Mar
(3) |
Apr
(30) |
May
(18) |
Jun
|
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2002 |
Jan
(7) |
Feb
(2) |
Mar
(1) |
Apr
|
May
|
Jun
(3) |
Jul
(13) |
Aug
|
Sep
(23) |
Oct
(180) |
Nov
(291) |
Dec
(95) |
| 2003 |
Jan
(338) |
Feb
(352) |
Mar
(97) |
Apr
(46) |
May
(226) |
Jun
(184) |
Jul
(145) |
Aug
(141) |
Sep
(69) |
Oct
(161) |
Nov
(96) |
Dec
(90) |
| 2004 |
Jan
(66) |
Feb
(87) |
Mar
(98) |
Apr
(132) |
May
(115) |
Jun
(68) |
Jul
(150) |
Aug
(92) |
Sep
(59) |
Oct
(52) |
Nov
(17) |
Dec
(75) |
| 2005 |
Jan
(84) |
Feb
(191) |
Mar
(133) |
Apr
(114) |
May
(158) |
Jun
(185) |
Jul
(62) |
Aug
(28) |
Sep
(36) |
Oct
(88) |
Nov
(65) |
Dec
(43) |
| 2006 |
Jan
(85) |
Feb
(62) |
Mar
(92) |
Apr
(75) |
May
(68) |
Jun
(101) |
Jul
(73) |
Aug
(37) |
Sep
(91) |
Oct
(65) |
Nov
(30) |
Dec
(39) |
| 2007 |
Jan
(24) |
Feb
(28) |
Mar
(10) |
Apr
(2) |
May
(18) |
Jun
(16) |
Jul
(21) |
Aug
(6) |
Sep
(30) |
Oct
(31) |
Nov
(153) |
Dec
(31) |
| 2008 |
Jan
(63) |
Feb
(70) |
Mar
(47) |
Apr
(24) |
May
(59) |
Jun
(22) |
Jul
(12) |
Aug
(7) |
Sep
(14) |
Oct
(26) |
Nov
(5) |
Dec
(5) |
| 2009 |
Jan
(10) |
Feb
(41) |
Mar
(70) |
Apr
(88) |
May
(49) |
Jun
(62) |
Jul
(34) |
Aug
(15) |
Sep
(55) |
Oct
(40) |
Nov
(67) |
Dec
(21) |
| 2010 |
Jan
(60) |
Feb
(17) |
Mar
(26) |
Apr
(26) |
May
(29) |
Jun
(4) |
Jul
(21) |
Aug
(21) |
Sep
(10) |
Oct
(12) |
Nov
(3) |
Dec
(19) |
| 2011 |
Jan
(3) |
Feb
(13) |
Mar
(8) |
Apr
(8) |
May
(17) |
Jun
(20) |
Jul
(21) |
Aug
(7) |
Sep
|
Oct
|
Nov
(9) |
Dec
(11) |
| 2012 |
Jan
(3) |
Feb
|
Mar
|
Apr
(5) |
May
(4) |
Jun
(14) |
Jul
(5) |
Aug
(2) |
Sep
(15) |
Oct
(2) |
Nov
(23) |
Dec
(1) |
| 2013 |
Jan
(8) |
Feb
(1) |
Mar
|
Apr
|
May
(5) |
Jun
(1) |
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(12) |
Nov
(10) |
Dec
(3) |
| 2014 |
Jan
(7) |
Feb
(14) |
Mar
(2) |
Apr
|
May
(2) |
Jun
(11) |
Jul
(10) |
Aug
(4) |
Sep
|
Oct
(8) |
Nov
(1) |
Dec
(2) |
| 2015 |
Jan
(9) |
Feb
(7) |
Mar
(1) |
Apr
|
May
(7) |
Jun
|
Jul
(5) |
Aug
(6) |
Sep
|
Oct
(1) |
Nov
(4) |
Dec
|
| 2016 |
Jan
(1) |
Feb
(1) |
Mar
(4) |
Apr
(2) |
May
(1) |
Jun
|
Jul
(6) |
Aug
(8) |
Sep
(21) |
Oct
(17) |
Nov
|
Dec
(36) |
| 2017 |
Jan
(6) |
Feb
(2) |
Mar
(4) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(6) |
| 2018 |
Jan
(2) |
Feb
(3) |
Mar
(3) |
Apr
(14) |
May
(2) |
Jun
(2) |
Jul
(4) |
Aug
(3) |
Sep
(6) |
Oct
(16) |
Nov
(1) |
Dec
(6) |
| 2019 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
(6) |
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
(7) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(2) |
Dec
(1) |
| 2021 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(5) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
|
From: Barry W. <bar...@gm...> - 2007-11-19 19:38:12
|
OMG. I'm an idiot. It's there. I'm blind. Sorry for the inbox spam! barry On Nov 19, 2007 11:37 AM, Barry Wark <bar...@gm...> wrote: > sorry. it looks like PyObjCTools are included in the system python in > Leopard. I don't see it in the pyobjc2 svn tree, however. Is the > intention that pyobjc 1.4 also be installed along with pyobjc2? > > thanks, > barry > > > On Nov 18, 2007 11:12 PM, Barry Wark <bar...@gm...> wrote: > > Is there an equivalent of PyObjCTools.installVerboseExceptionHanlder > > in pyobjc2 (or perhaps a better way)? > > > > thanks, > > Barry > > > |
|
From: Barry W. <bar...@gm...> - 2007-11-19 19:37:03
|
sorry. it looks like PyObjCTools are included in the system python in Leopard. I don't see it in the pyobjc2 svn tree, however. Is the intention that pyobjc 1.4 also be installed along with pyobjc2? thanks, barry On Nov 18, 2007 11:12 PM, Barry Wark <bar...@gm...> wrote: > Is there an equivalent of PyObjCTools.installVerboseExceptionHanlder > in pyobjc2 (or perhaps a better way)? > > thanks, > Barry > |
|
From: Barry W. <bar...@gm...> - 2007-11-19 07:12:51
|
Is there an equivalent of PyObjCTools.installVerboseExceptionHanlder in pyobjc2 (or perhaps a better way)? thanks, Barry |
|
From: Barry W. <bar...@gm...> - 2007-11-19 02:25:30
|
Just a follow up to this post with a possible solution... It looks like the problem building pyobjc2 with the Framework python build from python.org was using the 10.4u SDK rather than the 10.5 SDK. Removing the "-isysroot /Developer/SKDs/MacOSX10.4u.sdk" from /Library/Python/.../lib/config/Makefile (generated by python's configure script) seems to allow pyobjc to build, and pass all unit tests using the python.org Framework build (installed in /Library/Frameworks). I'm not sure what the concequences of removing the isysroot flag from Python's Makefile are. At least for a temporary fix, it's easier than compiling a new Framework build from source. Just FYI, Barry On Nov 8, 2007 4:10 PM, Barry Wark <bar...@gm...> wrote: > Given recent traffic on the pythonmac-sig, it sounds like the system > python on Leopard goes out of its way to put the site-packages > directory in /Library last on the sys.path. So, if we want to write > python apps that use newer versions of, e.g., numpy than those that > shipped with Leopard, we're SOL unless we want to go through some > PYTHONPATH contortions. The easy solution is to install MacPython into > /Library/Frameworks. Then the system python and the user-updated > python can be easily separated. > > I've so far been unable to install pyobjc2 on Leopard using MacPython > 2.5.1. It sounds like I'm having similar problems to the OP (output > of ./02-develop-all.sh is included; is 02-develop-all.sh the correct > way to build/install the entire package?). As Ronald mentioned, it > looks like this is because the 10.4u SDK is being used. Is there a way > to specify building using the 10.5 SDK and will this build work with > the MacPython 2.5.1 (dowloaded as a DMG from python.org) which is > presumably built with the 10.4u SDK? > > thanks, > Barry > > > On Nov 7, 2007 11:19 PM, Ronald Oussoren <ron...@ma...> wrote: > > > > On 8 Nov, 2007, at 7:14, Seungchan Oh wrote: > > > > > Hello, > > > > > > I'm having a difficulty to install PyObjC2.0 at Leopard with MacBook > > > Pro. > > > > I haven't tried building on 10.4 for a while (which is what you're > > basicly trying to do because you're using the 10.4 SDK). Appearently > > there are some issues there. > > > > Note that PyObjC 2.0 definitely requires some work to be useful on > > Tiger systems because Tiger doesn't ship with bridgesupport files and > > PyObjC 2 requires those files to provide full bindings. Generating > > bridgesupport files is easy enough, but not a priority for me right > > now because building them takes a lot of time (for the computer, the > > task barely requires interaction with a human) and I'm currently > > thinking about some changes that would require rebuilding the > > bridgesupport files anyway. > > > > BTW. You do know that Leopard ships with a perfectly fine copy of > > Python 2.5 and PyObjC 2.0? At this point in time it would be easier to > > use that instead of trying to rebuild PyObjC from scratch. > > > > Ronald > > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > Pyobjc-dev mailing list > > Pyo...@li... > > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > > > |
|
From: Bill B. <bb...@ma...> - 2007-11-19 01:22:10
|
On Nov 18, 2007, at 1:10 PM, James R Eagan wrote:
> It appears that PyObjC applications built with py2app on Leopard
> fail the codesign integrity checks. I have an application that uses
> a simple ObjC wrapper around the
> SecKeychain{Add,Find}GenericPassword methods. When I build and run
> the application from an XCode project, the application runs fine,
> adding and finding passwords on the keychain. When I build and run
> the same project using py2app, Leopard gripes when reading from the
> Keychain:
>
> "KeychainError - code or signature modified"
>
> At first I thought it might be the stripping phase, since I see the
> following warning when building, but the keychain error arises even
> if I pass --no-strip to py2app. In my case, it's easy enough to
> work-around by using XCode, but is this a known bug in py2app or
> something I might be doing wrong. (If it's the latter, I'd be happy
> to provide a small demonstration app, if necessary.)
Might it be that py2app is copying, then stripping, the
keychain.framework?
b.bum
|
|
From: James R E. <ea...@ba...> - 2007-11-18 21:10:55
|
Hi folks,
It appears that PyObjC applications built with py2app on Leopard fail
the codesign integrity checks. I have an application that uses a
simple ObjC wrapper around the SecKeychain{Add,Find}GenericPassword
methods. When I build and run the application from an XCode project,
the application runs fine, adding and finding passwords on the
keychain. When I build and run the same project using py2app, Leopard
gripes when reading from the Keychain:
"KeychainError - code or signature modified"
At first I thought it might be the stripping phase, since I see the
following warning when building, but the keychain error arises even if
I pass --no-strip to py2app. In my case, it's easy enough to work-
around by using XCode, but is this a known bug in py2app or something
I might be doing wrong. (If it's the latter, I'd be happy to provide
a small demonstration app, if necessary.)
Thanks!
James
% python setup.py py2app
[...]
/usr/bin/strip: changes being made to the file will invalidate the
code signature in: /Users/eaganj/Projects/PyLogin Authenticator/dist/
Login Authenticator.app/Contents/MacOS/LoginAuthenticator (for
architecture ppc7400)
/usr/bin/strip: changes being made to the file will invalidate the
code signature in: /Users/eaganj/Projects/PyLogin Authenticator/dist/
Login Authenticator.app/Contents/MacOS/LoginAuthenticator (for
architecture i386)
/usr/bin/strip: changes being made to the file will invalidate the
code signature in: /Users/eaganj/Projects/PyLogin Authenticator/dist/
Login Authenticator.app/Contents/MacOS/python (for architecture ppc7400)
/usr/bin/strip: changes being made to the file will invalidate the
code signature in: /Users/eaganj/Projects/PyLogin Authenticator/dist/
Login Authenticator.app/Contents/MacOS/python (for architecture i386)
/usr/bin/strip: for architecture ppc64 object: /Users/eaganj/Projects/
PyLogin Authenticator/dist/Login Authenticator.app/Contents/Frameworks/
Python.framework/Versions/2.5/Python malformed object (load command 3
cmdsize not a multiple of 8)
stripping saved 13880 bytes (16642820 / 16656700)
---------
setup.py:
---------
from distutils.core import setup
import py2app
from plistlib import Plist
SHORT_VERSION = '1.0'
BUNDLE_VERSION = '12'
plist = Plist.fromFile('Info-py2app.plist')
plist.update(dict(
CFBundleShortVersionString=SHORT_VERSION,
CFBundleVersion=BUNDLE_VERSION,
))
py2app_options = dict(
# iconfile='Login Authenticator.icns',
plist=plist,
frameworks=['KeychainServices.framework'],
)
setup(
app=['main.py'],
data_files=['MainMenu.nib'],
options=dict(
py2app=py2app_options
)
)
--
There are more of them than us. -- Herb Caen
|
|
From: Barry W. <bar...@gm...> - 2007-11-14 21:38:54
|
Has anyone successfully compiled/installed PyObjC 2 using the framework build python from python.org on Leopard? It looks like it's an issue of the development target of the framework (10.4) versus pyobjc2 (10.5) (see my prev. post under "[Pyobjc-dev] Got a problem to install PyObjC2.0"). Has anyone successfully installed pyobjc2 under leopard with the python.org framework python build? If so, would you be willing to share your experience? thanks, Barry |
|
From: Ben A. <be...@ar...> - 2007-11-14 20:02:49
|
I am trying to bridge UCConvertUTCDateTimeToCFAbsoluteTime using
PyObjC in Leopard.
The problem that I am running into is that
UCConvertUTCDateTimeToCFAbsoluteTime takes a struct that's declared
(on 32 bits) as {unsigned short; unsigned long; unsigned short;} using
packed alignment, which means that the offset of the 4-byte long
member is 2. When I use {UTCDateTime=SLS}, PyObjC puts the 4-byte long
at offset 4, which then causes problems down the line.
Looking at PyObjC source, I don't see a way to force custom alignment
of struct members.
Did I miss some mechanism for handling this? What are my option? Thanks,
Ben
--
<http://artins.org/ben>
"Youth cannot know how age thinks and feels. But old men are guilty
if they forget what it was to be young" -- Albus Dumbledore
|
|
From: Ronald O. <ron...@ma...> - 2007-11-14 07:02:08
|
On 14 Nov, 2007, at 2:10, Bobby Powers wrote:
> Hi, I'm relatively new to this, but I've been trying for the past 2
> days to get this working and have scoured the internet, so I figured
> its time to try the mailing list (I've looked through some of these
> archives, too).
>
> I am trying to add support to pyCairo for Cairo's Quartz backend.
> Specifically I am working on a wrapper function that needs the
> CGContextRef for the current screen to create the Cairo surface.
>
> In the test program (reproduced below), i get the context using
> NSGraphicsContext.currentContext().graphicsPort() and pass this to
> the function to create the surface, which is written in C. (As an
> aside, I read in some older mails to import Quartz when the
> applicationDidFinishLaunching method in a delagate was invoked.
> drawRect for me was being called before that, so I switched it to
> the view's init function and it seems to work fine). It took me a
> while to figure out the format strings in PyArg_ParseTuple and I may
> still not be doing them right... but the long and short of it is I
> can't get the CGContextRef in C from Python. I tried typecasting
> the PyObject to CGContextRef, and I've tried PyCObject_AsVoidPtr
> (but the PyObject passed is of the type 'CGContext' and not a
> PyCObject... so I'm not sure what to do.
>
> I am new, so if something like this is explained somewhere (or there
> is a better place to go for help), please let me know. Thanks!
> (and I hope this email formatting comes through alright...)
someContext.__cobject__() returns a PyCObject, PyCObject_AsVoidPtr can
then be used to extract the CGContextRef from C.
Ronald
>
> yours,
> Bobby
>
> ----------
>
> simplified test class:
> from Foundation import *
> from AppKit import *
>
> import cairo
>
> class CairoView(NSView):
> def initWithFrame_(self, frame):
> self = super(CairoView, self).initWithFrame_(frame)
> if self:
> import Quartz
> return self
>
> def drawRect_(self, rect):
> context = NSGraphicsContext.currentContext().graphicsPort()
> surface = cairo.QuartzSurface(context, 200, 200)
>
>
> wrapper function:
> static PyObject *
> quartz_surface_new (PyTypeObject *type, PyObject *args, PyObject
> *kwds)
> {
>
> PyObject *pyContext;
> float width, height;
>
> if (!PyArg_ParseTuple (args, "Off:QuartzSurface.__new__",
> &pyContext, &width, &height))
> return NULL;
>
> CGContextRef ctx = (CGContextRef)(void *)pyContext;
>
> // Make the CGContext coordinate system sane, as expected by Cairo
> CGContextTranslateCTM (ctx, 0.0, height);
> CGContextScaleCTM (ctx, 1.0, -1.0);
>
>
> return PycairoSurface_FromSurface (
>
> cairo_quartz_surface_create_for_cg_context (ctx, width, height),
> NULL);
> }
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a
> browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/_______________________________________________
> Pyobjc-dev mailing list
> Pyo...@li...
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
|
|
From: Bobby P. <bob...@gm...> - 2007-11-14 01:10:20
|
Hi, I'm relatively new to this, but I've been trying for the past 2
days to get this working and have scoured the internet, so I figured
its time to try the mailing list (I've looked through some of these
archives, too).
I am trying to add support to pyCairo for Cairo's Quartz backend.
Specifically I am working on a wrapper function that needs the
CGContextRef for the current screen to create the Cairo surface.
In the test program (reproduced below), i get the context using
NSGraphicsContext.currentContext().graphicsPort() and pass this to the
function to create the surface, which is written in C. (As an aside, I
read in some older mails to import Quartz when the
applicationDidFinishLaunching method in a delagate was invoked.
drawRect for me was being called before that, so I switched it to the
view's init function and it seems to work fine). It took me a while
to figure out the format strings in PyArg_ParseTuple and I may still
not be doing them right... but the long and short of it is I can't get
the CGContextRef in C from Python. I tried typecasting the PyObject
to CGContextRef, and I've tried PyCObject_AsVoidPtr (but the PyObject
passed is of the type 'CGContext' and not a PyCObject... so I'm not
sure what to do.
I am new, so if something like this is explained somewhere (or there
is a better place to go for help), please let me know. Thanks! (and
I hope this email formatting comes through alright...)
yours,
Bobby
----------
simplified test class:
from Foundation import *
from AppKit import *
import cairo
class CairoView(NSView):
def initWithFrame_(self, frame):
self = super(CairoView, self).initWithFrame_(frame)
if self:
import Quartz
return self
def drawRect_(self, rect):
context = NSGraphicsContext.currentContext().graphicsPort()
surface = cairo.QuartzSurface(context, 200, 200)
wrapper function:
static PyObject *
quartz_surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *pyContext;
float width, height;
if (!PyArg_ParseTuple (args, "Off:QuartzSurface.__new__",
&pyContext, &width, &height))
return NULL;
CGContextRef ctx = (CGContextRef)(void *)pyContext;
// Make the CGContext coordinate system sane, as expected by Cairo
CGContextTranslateCTM (ctx, 0.0, height);
CGContextScaleCTM (ctx, 1.0, -1.0);
return PycairoSurface_FromSurface (
cairo_quartz_surface_create_for_cg_context (ctx, width, height),
NULL);
}
|
|
From: Ronald O. <ron...@ma...> - 2007-11-13 08:31:57
|
On Tuesday, November 13, 2007, at 08:53AM, "Luc Heinrich" <lu...@ho...> wrote: >On 13 nov. 07, at 00:24, Bill Bumgarner wrote: > >> The injecting process will, at the least, need to be in a >> particular group/user (that I can't remember right now). Try >> injecting as root and see if it works (as root can do all). The group was 'procmod' on Tiger/x86, I'd guess it is the same on Leopard. > >Trying to inject as root causes a segfault, so at least something is >happening... :) objc.inject isn't tested automaticly and not something I use very often (basicly only at demo's), hence it can break without me noticing that. Yet another item for my todo list :-( Ronald > >Process: Python [6466] >Path: /System/Library/Frameworks/Python.framework/Versions/ >2.5/Resources/Python.app/Contents/MacOS/Python >Identifier: Python >Version: ??? (???) >Code Type: PPC (Native) >Parent Process: bash [6445] > >Date/Time: 2007-11-13 08:47:39.189 +0100 >OS Version: Mac OS X 10.5 (9A581) >Report Version: 6 > >Exception Type: EXC_BAD_ACCESS (SIGSEGV) >Exception Codes: KERN_INVALID_ADDRESS at 0x00000000ffffffff >Crashed Thread: 0 > >Thread 0 Crashed: >0 _objc.so 0x0028f9c0 machImageForPointer + 280 >1 _objc.so 0x0028fb08 mach_inject + 60 >2 _objc.so 0x0029b0c4 objc_inject + 1116 >3 _objc.so 0x0029499c >PyObjCMethodSignature_AsDict + 8940 >4 org.python.python 0x00143f68 PyObject_Call + 48 >5 org.python.python 0x001c72bc PyEval_EvalFrameEx + 18200 >6 org.python.python 0x001c8a34 PyEval_EvalCodeEx + 2048 >7 org.python.python 0x001c6cc4 PyEval_EvalFrameEx + 16672 >8 org.python.python 0x001c8a34 PyEval_EvalCodeEx + 2048 >9 org.python.python 0x001c8b54 PyEval_EvalCode + 44 >10 org.python.python 0x001e3554 PyErr_Display + 2100 >11 org.python.python 0x001e3c98 PyRun_FileExFlags + 148 >12 org.python.python 0x001e5868 PyRun_SimpleFileExFlags >+ 424 >13 org.python.python 0x001f2374 Py_Main + 2808 >14 org.python.pythonapp 0x00001f84 0x1000 + 3972 > >Thread 0 crashed with PPC Thread State 32: > srr0: 0x0028f9c0 srr1: 0x0200f030 dar: 0xffffffff dsisr: >0x40000000 > r0: 0x0028f9bc r1: 0xbffff160 r2: 0xa046f540 r3: >0xffffffff > r4: 0x0009efec r5: 0x00000001 r6: 0x00000000 r7: >0x00000003 > r8: 0x00000000 r9: 0x00000000 r10: 0x8fe0396c r11: >0xa0436898 > r12: 0x91f21cdc r13: 0x00000171 r14: 0x00021c94 r15: >0x0056dedc > r16: 0x0057c37c r17: 0x002bac7c r18: 0x002bac7c r19: >0x0000008c > r20: 0xbffff268 r21: 0xbffff26c r22: 0xbffff274 r23: >0xcafebabe > r24: 0xbffff270 r25: 0x00276000 r26: 0x0000005b r27: >0x0029a6bc > r28: 0x00000003 r29: 0x0009efec r30: 0xffffffff r31: >0x0028f8bc > cr: 0x84442448 xer: 0x00000004 lr: 0x0028f9bc ctr: >0x91f21cdc >vrsave: 0x00000000 > >... >... > >-- >Luc Heinrich > > > >------------------------------------------------------------------------- >This SF.net email is sponsored by: Splunk Inc. >Still grepping through log files to find problems? Stop. >Now Search log events and configuration files using AJAX and a browser. >Download your FREE copy of Splunk now >> http://get.splunk.com/ >_______________________________________________ >Pyobjc-dev mailing list >Pyo...@li... >https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > |
|
From: Luc H. <lu...@ho...> - 2007-11-13 07:53:16
|
On 13 nov. 07, at 00:24, Bill Bumgarner wrote:
> The injecting process will, at the least, need to be in a
> particular group/user (that I can't remember right now). Try
> injecting as root and see if it works (as root can do all).
Trying to inject as root causes a segfault, so at least something is
happening... :)
Process: Python [6466]
Path: /System/Library/Frameworks/Python.framework/Versions/
2.5/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: ??? (???)
Code Type: PPC (Native)
Parent Process: bash [6445]
Date/Time: 2007-11-13 08:47:39.189 +0100
OS Version: Mac OS X 10.5 (9A581)
Report Version: 6
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000ffffffff
Crashed Thread: 0
Thread 0 Crashed:
0 _objc.so 0x0028f9c0 machImageForPointer + 280
1 _objc.so 0x0028fb08 mach_inject + 60
2 _objc.so 0x0029b0c4 objc_inject + 1116
3 _objc.so 0x0029499c
PyObjCMethodSignature_AsDict + 8940
4 org.python.python 0x00143f68 PyObject_Call + 48
5 org.python.python 0x001c72bc PyEval_EvalFrameEx + 18200
6 org.python.python 0x001c8a34 PyEval_EvalCodeEx + 2048
7 org.python.python 0x001c6cc4 PyEval_EvalFrameEx + 16672
8 org.python.python 0x001c8a34 PyEval_EvalCodeEx + 2048
9 org.python.python 0x001c8b54 PyEval_EvalCode + 44
10 org.python.python 0x001e3554 PyErr_Display + 2100
11 org.python.python 0x001e3c98 PyRun_FileExFlags + 148
12 org.python.python 0x001e5868 PyRun_SimpleFileExFlags
+ 424
13 org.python.python 0x001f2374 Py_Main + 2808
14 org.python.pythonapp 0x00001f84 0x1000 + 3972
Thread 0 crashed with PPC Thread State 32:
srr0: 0x0028f9c0 srr1: 0x0200f030 dar: 0xffffffff dsisr:
0x40000000
r0: 0x0028f9bc r1: 0xbffff160 r2: 0xa046f540 r3:
0xffffffff
r4: 0x0009efec r5: 0x00000001 r6: 0x00000000 r7:
0x00000003
r8: 0x00000000 r9: 0x00000000 r10: 0x8fe0396c r11:
0xa0436898
r12: 0x91f21cdc r13: 0x00000171 r14: 0x00021c94 r15:
0x0056dedc
r16: 0x0057c37c r17: 0x002bac7c r18: 0x002bac7c r19:
0x0000008c
r20: 0xbffff268 r21: 0xbffff26c r22: 0xbffff274 r23:
0xcafebabe
r24: 0xbffff270 r25: 0x00276000 r26: 0x0000005b r27:
0x0029a6bc
r28: 0x00000003 r29: 0x0009efec r30: 0xffffffff r31:
0x0028f8bc
cr: 0x84442448 xer: 0x00000004 lr: 0x0028f9bc ctr:
0x91f21cdc
vrsave: 0x00000000
...
...
--
Luc Heinrich
|
|
From: Bill B. <bb...@ma...> - 2007-11-12 23:25:22
|
On Nov 12, 2007, at 1:53 PM, Luc Heinrich wrote: > Is code injection still supposed to work on Leopard ? I can't get any > of the samples to work. I have especially tried InjectInterpreter and > no matter what I do, nothing seems to happen. No error message, no > interpreter window popping up in the target process, nothing. The injecting process will, at the least, need to be in a particular group/user (that I can't remember right now). Try injecting as root and see if it works (as root can do all). b.bum |
|
From: David B. <db3...@gm...> - 2007-11-12 22:46:09
|
Antonio <str...@ti...> writes:
> I've read the example in twisted documentation ,but I don't understand HOW
> make the pb client work ... this is the code:
I think more of your issues are Twisted related rather than
PyObjC/Cocoa, and you might be complicating your life by trying to
work up two learning curves at the same time. What I might suggest is
that you experiment with getting working code independent of
PyObjC/Cocoa integration, to simplify interaction problems as you get
used to Twisted and PB. Also questions at that point are probably
best handled on the Twisted mailing list where you'll likely find more
people with appropriate experience to help out.
I can't run your actual code without the other pieces, and you don't
indicate precisely what errors you're getting, but you appear to be
mixing non-PB client startup (your attempt to use Client as a
protocol, and start it with ClientCreator), with a PB client
construction (via pb.ClientFactory). Trying to use the PB code from
within an instance of a non-PB protocol object is backwards, and too
late. You're also not taking into account that getRootObject returns
a deferred since the connection may not yet have been made at the
point when the method is being called.
For PB, a connection is handled by the pb.ClientFactory factory
object, using a pb.Broker object instance as its protocol. E.g., the
"protocol" in Twisted terms for PB is the class managing share object
instances and their serialization/deserialization across the wire. So
you never replace the actual protocol for the session.
Here's a pretty minimal example of a PB client/server combination
(without authentication) that uses an echo call. I've implemented the
client as a standalone object, so you should be able to insert the
__main__ block (aside from the reactor.run) into your UI code in lieu
of your current ClientCreator() call if you like.
Here I use a standard ClientFactory object - other choices are to
subclass that object (if for example, you want to handle automatic
reconnects). Or, if you are using authentication, the factory's
login() method should be used in lieu of getRootObject, since it
handles authentication through the Portal on the server side, and its
callback eventually hands you the root object.
-- David
- - - - - - - - - - Server - - - - - - - - - -
from twisted.internet import reactor
from twisted.spread import pb
class Root(pb.Root):
def remote_echo(self, value):
return value
if __name__ == '__main__':
reactor.listenTCP(8789, pb.PBServerFactory(Root()))
reactor.run()
- - - - - - - - - - Client - - - - - - - - - -
from twisted.internet import reactor
from twisted.spread import pb
class Client(object):
def __init__(self, factory):
factory.getRootObject().addCallbacks(self.gotRoot, self.failure)
def _done(self):
reactor.stop()
def failure(self, failure):
print 'Network failure'
print failure
self._done()
def gotRoot(self, root):
self.root = root
d = self.root.callRemote('echo', 'value')
d.addCallbacks(self.echoResponse, self.failure)
def echoResponse(self, value):
print 'Echo response:', value
self._done()
if __name__ == "__main__":
factory = pb.PBClientFactory()
reactor.connectTCP("localhost", 8789, factory)
client = Client(factory)
reactor.run()
|
|
From: Luc H. <lu...@ho...> - 2007-11-12 21:53:34
|
Greetings, Is code injection still supposed to work on Leopard ? I can't get any of the samples to work. I have especially tried InjectInterpreter and no matter what I do, nothing seems to happen. No error message, no interpreter window popping up in the target process, nothing. -- Luc Heinrich |
|
From: Antonio <str...@ti...> - 2007-11-12 16:18:20
|
hi all,
I've read the example in twisted documentation ,but I don't understand HOW
make the pb client work ... this is the code:
[CODE]
import objc
from Foundation import *
from AppKit import *
from PyObjCTools import NibClassBuilder, AppHelper
from twisted.internet import _threadedselect
_threadedselect.install()
from twisted.spread import pb
from twisted.internet import reactor, protocol, defer
from twisted.python import util, log
from twisted.protocols import basic
import sys
NibClassBuilder.extractClasses("MainMenu")
class Client(object):
def __init__(self, parent):
super(Client, self).__init__()
print 'init'
self.parent = parent
self.factory = pb.PBClientFactory()
self.root = self.factory.getRootObject()
self.root.debug = True
print self.root
self.root.addCallback(self.getEcho)
#_d.addCallback(self.printRes)
#_d.addCallback(self.parent._fillNome)
self.root.addErrback(self.errore)
def errore(self, msg):
print 'errore:', msg
def printRes(self, data):
print 'res', data
def getEcho(self, obj):
print
print '-'*20
print 'chiamo', obj
print '-'*20
print
_val = obj.callRemote("echo", "sasso")
return _val
def __call__(self):
print
print 'CCCALLL'
print
# class defined in MainMenu.nib
class MyObject(NibClassBuilder.AutoBaseClass):
# the actual base class is NSObject
# The following outlets are added to the class:
# ind
# nome
# piva
def init(self):
self = super(MyObject, self).init()
return self
def salva_(self, sender):
self.piva.setStringValue_('vaffanculo')
def trova_(self, sender):
protocol.ClientCreator(reactor, Client, self).connectTCP(
"a.s.h", 8789)
def _fillNome(self, strng):
print 'ricevo', strng
self.nome.setStringValue_(strng)
def _errore(self, err):
self.ind.setStringValue_('ERRORE: %s' % err)
def applicationDidFinishLaunching_(self, aNotification):
print
print 'finish launching'
print
reactor.interleave(AppHelper.callAfter, self._fillNome)
def applicationShouldTerminate_(self, sender):
if reactor.running:
reactor.stop()
return False
return True
if __name__ == "__main__":
log.startLogging(sys.stdout)
AppHelper.runEventLoop()
tanks in advance ...
--
#include <stdio.h>
int main(void){char c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110,
101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,101,
116,46,105,116,62,10,10,0};printf("%s",c);return 0;}
|
|
From: Diez B. R. <de...@we...> - 2007-11-12 13:36:53
|
On Friday 09 November 2007 15:44:11 Yaniv Aknin wrote: > As I'm using Tiger, sounds to me like I might be better off writing the > code which deals with DiskArbitration in C, and using that in my Python > program using a C API. What would you do in my case? Use ctypes. Diez |
|
From: Uliano G. <gue...@gm...> - 2007-11-12 08:35:19
|
Il giorno 11/nov/07, alle ore 17:24, Ronald Oussoren ha scritto: > > On 11 Nov, 2007, at 16:31, Uliano Guerrini wrote: > >> >> def newf(): >> a=numpy.zeros((256,256),dtype='float32') >> for x in range(0,256): >> a[:,x]=x/255.0 >> return a.tostring() >> >> def cff(): >> return Foundation.CFDataCreateWithBytesNoCopy(None,newf(), >> 65536*4,None) >> >> changing between CFDataCreate and CFDataCreateWithBytesNoCopy makes >> the difference from expected image and crappy noise > > That's the expected behaviour, albeith one that is a bit annoying. well, I'm newbie to pyobjc and to some extent also to python, however I didn't expect (and can't explain) it: it seems to work in a way when I try simple example on the python console and in another inside the image synthesis routine however I found that also NSData.dataWithBytes.NoCopy_Length_ has the same (unexpected for me) behaviour > There is however a better way to convert a python object to an > NSData/CFData without copying: if the object supports the buffer > protocol, which strings and numpy arrays do, you can use > buffer(myObject) to get a buffer object. That object is bridged as > an NSData object, without copying data. this works in that contex, however I don't understand to what extent it is bridged: I passed it to a CF routine and worked as a CFData but does not respond to NSData methods like .bytes() I guess that as this bridged buffer there are other bags of tricks about PyObjc, where can I look for them? uliano |
|
From: Bill B. <bb...@ma...> - 2007-11-12 01:46:06
|
On Nov 11, 2007, at 1:23 PM, Chris McClimans wrote:
> class Person(NSObject):
> personName = objc.ivar()
> expectedRaise = objc.ivar.float()
> def setExpectedRaise_(self, expectedRaise):
> self.expectedRaise = expectedRaise
> def setPersonName_(self, personName):
> self.personName = personName
>
> It looks like it should work fine for KVC, however the trailing
> underscores on the setAttribute_ calls are not valid. If you replace
> the colons in the objective-c calls with underscores in python as I
> have seen else where, you will get an error when using KVC via an
> NSArrayController.
>
> An unexpected error occured: (AttributeError: 'Person' object has no
> attribute 'setExpectedRaise')
>
> This is resolved when removing the trailing underscore from the method
> call.
>
> Is this an exception to the replace colons in objective-c with
> underscores in python rule?
The above code looks slightly unexpected. Namely, it doesn't
implement the -expectedRaise and -personName instance methods.
Try implementing expectedRaise() and personName() methods (moving the
iVars to _personName and _expectedRaise) most likely.
It is likely that NSArrayController is confused by the lack of the
expected method pair.
Note that it is NSAC that is tripping over this, not KVC:
>>> from Foundation import *
>>> from objc import *
>>> class Person(NSObject):
... personName = objc.ivar()
... expectedRaise = objc.ivar.float()
... def setExpectedRaise_(self, expectedRaise):
... self.expectedRaise = expectedRaise
... def setPersonName_(self, personName):
... self.personName = personName
...
>>> x = Person.new()
>>> x.valueForKey_("expectedRaise")
0.0
>>> x.setValue_forKey_(10.0, "expectedRaise")
>>> x.valueForKey_("expectedRaise")
10.0
>>> x.expectedRaise
10.0
>>> x.setExpectedRaise_
<selector setExpectedRaise: of <Person: 0x1ae7490>>
(stock Leopard)
b.bum
|
|
From: Chris M. <pyo...@mc...> - 2007-11-11 21:23:48
|
Consider the following in objective-c:
@interface Person : NSObject {
NSString *personName;
float expectedRaise;
}
- (float)expectedRaise;
- (void)setExpectedRaise:(float)x;
- (NSString *)personName;
- (void)setPersonName:(NSString *)aName;
@end
It would make sense to implement it in python as follows:
class Person(NSObject):
personName = objc.ivar()
expectedRaise = objc.ivar.float()
def setExpectedRaise_(self, expectedRaise):
self.expectedRaise = expectedRaise
def setPersonName_(self, personName):
self.personName = personName
It looks like it should work fine for KVC, however the trailing
underscores on the setAttribute_ calls are not valid. If you replace
the colons in the objective-c calls with underscores in python as I
have seen else where, you will get an error when using KVC via an
NSArrayController.
An unexpected error occured: (AttributeError: 'Person' object has no
attribute 'setExpectedRaise')
This is resolved when removing the trailing underscore from the method
call.
Is this an exception to the replace colons in objective-c with
underscores in python rule?
-chris
|
|
From: Chris M. <pyo...@mc...> - 2007-11-11 20:23:33
|
I'm going through chapter six now, and I'm running into issues with
key value coding instance variables and how to create them. Using both
approaches in the documentation I can't seem to find a way to create a
NSString instance variable. I understand that I could just do
myvar=NSString.new() or myvar=objc.ivar('myvar') and not give it the
type, but neither of those seem to give me a full KVC instance
variable of a certain type.
From the NEWS.txt:
- It is now conveniently possible to create instance variables with
a specific type (e.g. without manually making up a encoded type
string)::
class MyObject (NSObject):
bounds = objc.ivar.NSRect()
done = objc.ivar.bool()
From simple-kvo.py:
class MyClass(NSObject):
base = objc.ivar("base", objc._C_INT)
power = objc.ivar("power", objc._C_INT)
I'm looking to implement an instance variable of type NSString, but
objc.ivar.NSString and objc._NSString do not exist for either approach.
objc.ivar.NSRect and objc._C_INT appear as utilized above, but
NSString seems to be missing.
If you only import objc, you get just the basic types:
In [1]: import objc
In [2]: objc.ivar. #hit tab
objc.ivar.__base__ objc.ivar.__bases__
objc.ivar.__basicsize__ objc.ivar.__call__
objc.ivar.__class__ objc.ivar.__class__
objc.ivar.__class__ objc.ivar.__class__
objc.ivar.__cmp__ objc.ivar.__delattr__
objc.ivar.__delattr__ objc.ivar.__delattr__
objc.ivar.__delete__ objc.ivar.__dict__
objc.ivar.__dictoffset__ objc.ivar.__doc__
objc.ivar.__doc__ objc.ivar.__doc__
objc.ivar.__flags__ objc.ivar.__get__
objc.ivar.__getattribute__ objc.ivar.__getattribute__
objc.ivar.__getattribute__ objc.ivar.__hash__
objc.ivar.__hash__ objc.ivar.__hash__
objc.ivar.__init__ objc.ivar.__init__
objc.ivar.__init__ objc.ivar.__itemsize__
objc.ivar.__module__ objc.ivar.__mro__
objc.ivar.__name__ objc.ivar.__new__
objc.ivar.__new__ objc.ivar.__new__
objc.ivar.__reduce__ objc.ivar.__reduce__
objc.ivar.__reduce__ objc.ivar.__reduce_ex__
objc.ivar.__reduce_ex__ objc.ivar.__reduce_ex__
objc.ivar.__repr__ objc.ivar.__repr__
objc.ivar.__repr__ objc.ivar.__set__
objc.ivar.__setattr__ objc.ivar.__setattr__
objc.ivar.__setattr__ objc.ivar.__str__
objc.ivar.__str__ objc.ivar.__subclasses__
objc.ivar.__weakrefoffset__ objc.ivar.bool
objc.ivar.char objc.ivar.double
objc.ivar.float objc.ivar.int
objc.ivar.long objc.ivar.long_long
objc.ivar.mro objc.ivar.short
objc.ivar.unsigned_char objc.ivar.unsigned_int
objc.ivar.unsigned_long objc.ivar.unsigned_long_long
objc.ivar.unsigned_short objc.ivar.__str__
Import Foundation and you get some more... but no NSString! Is there
something else I need to import?
In [2]: import Foundation
In [3]: objc.ivar. #hit tab
Display all 121 possibilities? (y or n)
objc.ivar.__base__
objc.ivar.__bases__
objc.ivar.__basicsize__ objc.ivar.__call__
objc.ivar.__class__
objc.ivar.__class__
objc.ivar.__class__ objc.ivar.__class__
objc.ivar.__cmp__
objc.ivar.__delattr__
objc.ivar.__delattr__ objc.ivar.__delattr__
objc.ivar.__delete__
objc.ivar.__dict__
objc.ivar.__dictoffset__ objc.ivar.__doc__
objc.ivar.__doc__
objc.ivar.__doc__
objc.ivar.__flags__ objc.ivar.__get__
objc.ivar.__getattribute__
objc.ivar.__getattribute__
objc.ivar.__getattribute__ objc.ivar.__hash__
objc.ivar.__hash__
objc.ivar.__hash__
objc.ivar.__init__ objc.ivar.__init__
objc.ivar.__init__
objc.ivar.__itemsize__
objc.ivar.__module__ objc.ivar.__mro__
objc.ivar.__name__
objc.ivar.__new__
objc.ivar.__new__ objc.ivar.__new__
objc.ivar.__reduce__
objc.ivar.__reduce__
objc.ivar.__reduce__ objc.ivar.__reduce_ex__
objc.ivar.__reduce_ex__
objc.ivar.__reduce_ex__
objc.ivar.__repr__ objc.ivar.__repr__
objc.ivar.__repr__
objc.ivar.__set__
objc.ivar.__setattr__ objc.ivar.__setattr__
objc.ivar.__setattr__
objc.ivar.__str__
objc.ivar.__str__ objc.ivar.__subclasses__
objc.ivar.__weakrefoffset__
objc.ivar.bool
objc.ivar.CFAllocatorContext objc.ivar.CFArrayCallBacks
objc.ivar.CFBagCallBacks
objc.ivar.CFBinaryHeapCallBacks
objc.ivar.CFBinaryHeapCompareContext
objc.ivar.CFDictionaryKeyCallBacks
objc.ivar.CFDictionaryValueCallBacks
objc.ivar.CFFileDescriptorContext
objc.ivar.CFGregorianDate objc.ivar.CFGregorianUnits
objc.ivar.CFMachPortContext
objc.ivar.CFMessagePortContext
objc.ivar.CFRange
objc.ivar.CFRunLoopObserverContext
objc.ivar.CFRunLoopSourceContext
objc.ivar.CFRunLoopTimerContext
objc.ivar.CFSetCallBacks objc.ivar.CFSocketContext
objc.ivar.CFSocketSignature
objc.ivar.CFStreamClientContext
objc.ivar.CFStreamError
objc.ivar.CFStringInlineBuffer
objc.ivar.CFSwappedFloat32
objc.ivar.CFSwappedFloat64
objc.ivar.CFTreeContext objc.ivar.CFUUIDBytes
objc.ivar.CFXMLAttributeDeclarationInfo
objc.ivar.CFXMLAttributeListDeclarationInfo
objc.ivar.CFXMLDocumentInfo
objc.ivar.CFXMLDocumentTypeInfo
objc.ivar.CFXMLElementInfo
objc.ivar.CFXMLElementTypeDeclarationInfo
objc.ivar.CFXMLEntityInfo
objc.ivar.CFXMLEntityReferenceInfo
objc.ivar.CFXMLExternalID
objc.ivar.CFXMLNotationInfo
objc.ivar.CFXMLParserCallBacks
objc.ivar.CFXMLParserContext
objc.ivar.CFXMLProcessingInstructionInfo
objc.ivar.char
objc.ivar.double objc.ivar.float
objc.ivar.int
objc.ivar.long
objc.ivar.long_long objc.ivar.mro
objc.ivar.NSAffineTransformStruct
objc.ivar.NSDecimal
objc.ivar.NSFastEnumerationState objc.ivar.NSHashEnumerator
objc.ivar.NSHashTableCallBacks
objc.ivar.NSMapEnumerator
objc.ivar.NSMapTableKeyCallBacks
objc.ivar.NSMapTableValueCallBacks
objc.ivar.NSPoint
objc.ivar.NSRange
objc.ivar.NSRect objc.ivar.NSSize
objc.ivar.NSSwappedDouble
objc.ivar.NSSwappedFloat
objc.ivar.short objc.ivar.unsigned_char
objc.ivar.unsigned_int
objc.ivar.unsigned_long
objc.ivar.unsigned_long_long objc.ivar.unsigned_short
objc.ivar.__str__
In [4]: objc.ivar.NSString
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
/Volumes/Raid/mcclimans/Src/pyobjc-20x-branch/<ipython console> in
<module>()
AttributeError: type object 'ivar' has no attribute 'NSString'
|
|
From: Ronald O. <ron...@ma...> - 2007-11-11 16:24:44
|
On 11 Nov, 2007, at 16:31, Uliano Guerrini wrote: > > Il giorno 10/nov/07, alle ore 16:24, Ronald Oussoren ha scritto: > >> >> On 10 Nov, 2007, at 9:58, Uliano Guerrini wrote: >> >>> Hi, >>> this code: >>> >>> cf=Foundation.CFDataCreate(None,string,len) >>> >>> works as expected, while: >>> >>> cf=Foundation.CFDataCreateWithBytesNoCopy(None,string,len,None) >>> >>> generates crap data. How can I fix this? >> >> both seem to work as expected. > > well now that I tried some simple typing on the terminal I have to > agree > > >> What might bite you is that you must make sure that 'string' is >> kept alive as long as you might access 'cf', Python's garbage >> collector doesn't (and cannot) know that >> CFDataCreateWithBytesNoCopy sneeks a reference to part of a Python >> object in the object it creates. >> >> Could you please create a demo program that demonstrates the >> problem you're having? > > the program for the moment is nonsensic experimenation, here are the > snippets causing the problem > > def newf(): > a=numpy.zeros((256,256),dtype='float32') > for x in range(0,256): > a[:,x]=x/255.0 > return a.tostring() > > def cff(): > return Foundation.CFDataCreateWithBytesNoCopy(None,newf(), > 65536*4,None) > > def dpf(): > return CGDataProviderCreateWithCFData(cff()) > > def imf(): > colorspace=CGColorSpaceCreateDeviceGray() > c=kCGImageAlphaNone | kCGBitmapFloatComponents | > kCGBitmapByteOrder32Little > return CGImageCreate(256,256,32,32,256*4,colorspace,c,dpf(),None, > 0,kCGRenderingIntentDefault) > > def cii(): > a=CIImage.imageWithCGImage_(imf()) > return a > > this core image is then plotted on a view with this method > > def drawRect_(self, rect): > ciicontext=NSGraphicsContext.currentContext().CIContext() > > ciicontext > .drawImage_inRect_fromRect_(NumpyCFImage.cii(),self.bounds(),((0,0), > (256,256))) > > changing between CFDataCreate and CFDataCreateWithBytesNoCopy makes > the difference from expected image and crapy noise That's the expected behaviour, albeith one that is a bit annoying. There is however a better way to convert a python object to an NSData/ CFData without copying: if the object supports the buffer protocol, which strings and numpy arrays do, you can use buffer(myObject) to get a buffer object. That object is bridged as an NSData object, without copying data. Ronald > > > uliano > >> > |
|
From: Uliano G. <gue...@gm...> - 2007-11-11 15:31:04
|
Il giorno 10/nov/07, alle ore 16:24, Ronald Oussoren ha scritto:
>
> On 10 Nov, 2007, at 9:58, Uliano Guerrini wrote:
>
>> Hi,
>> this code:
>>
>> cf=Foundation.CFDataCreate(None,string,len)
>>
>> works as expected, while:
>>
>> cf=Foundation.CFDataCreateWithBytesNoCopy(None,string,len,None)
>>
>> generates crap data. How can I fix this?
>
> both seem to work as expected.
well now that I tried some simple typing on the terminal I have to agree
> What might bite you is that you must make sure that 'string' is kept
> alive as long as you might access 'cf', Python's garbage collector
> doesn't (and cannot) know that CFDataCreateWithBytesNoCopy sneeks a
> reference to part of a Python object in the object it creates.
>
> Could you please create a demo program that demonstrates the problem
> you're having?
the program for the moment is nonsensic experimenation, here are the
snippets causing the problem
def newf():
a=numpy.zeros((256,256),dtype='float32')
for x in range(0,256):
a[:,x]=x/255.0
return a.tostring()
def cff():
return Foundation.CFDataCreateWithBytesNoCopy(None,newf(),
65536*4,None)
def dpf():
return CGDataProviderCreateWithCFData(cff())
def imf():
colorspace=CGColorSpaceCreateDeviceGray()
c=kCGImageAlphaNone | kCGBitmapFloatComponents |
kCGBitmapByteOrder32Little
return CGImageCreate(256,256,32,32,256*4,colorspace,c,dpf(),None,
0,kCGRenderingIntentDefault)
def cii():
a=CIImage.imageWithCGImage_(imf())
return a
this core image is then plotted on a view with this method
def drawRect_(self, rect):
ciicontext=NSGraphicsContext.currentContext().CIContext()
ciicontext.drawImage_inRect_fromRect_(NumpyCFImage.cii(),self.bounds(),
((0,0),(256,256)))
changing between CFDataCreate and CFDataCreateWithBytesNoCopy makes
the difference from expected image and crapy noise
uliano
>
|
|
From: Ronald O. <ron...@ma...> - 2007-11-11 12:59:17
|
On 11 Nov, 2007, at 9:48, Chris McClimans wrote:
> I've looked through the docs, but I can only guess I'm approaching
> this the wrong way as I work through Chapter 5 in Hillegass' Cocoa
> book via PyOjbc.
>
> If I want to do something that logs all calls to the
> respondsToSelector call to my class similar to this:
>
> - (BOOL)respondsToSelector:(SEL)aSelector
> {
> NSString *methodName = NSStringFromSelector(aSelector);
> NSLog(@"respondsToSelector:%@", methodName);
> return [super respondsToSelector:aSelector];
> }
>
> I would think I would implement something like this in PyObjc:
>
> class MyAppDelegate(NSObject):
> def respondsToSelector_(self, aSelector):
> NSLog('We Are Responding')
> return super(MyAppDelegate,self
> ).respondsToSelector_(self,aSelector)
>
> However I get a weird error about not being able to create IMP for
> instances of objc.native_selector:
>
> Traceback (most recent call last):
> File "/Volumes/Raid/mcclimans/MyApp/build/Release/MyApp.app/
> Contents/Resources/main.py", line 17, in <module>
> import TwiceAsTallAppDelegate
> File "/Volumes/Raid/mcclimans/MyApp/build/Release/MyApp.app/
> Contents/Resources/MyAppDelegate.py", line 12, in <module>
> class TwiceAsTallAppDelegate(NSObject):
> TypeError: Error when calling the metaclass bases
> Sorry, cannot create IMP for instances of type
> objc.native_selector
> 2007-11-11 01:36:53.971 MyApp[1227:10b] *** Terminating app due to
> uncaught exception 'NSInternalInconsistencyException', reason: '/
> Volumes/Raid/mcclimans/My/main.m:44 main() PyRun_SimpleFile failed
> with file '/Volumes/Raid/mcclimans/My/build/Release/MyApp.app/
> Contents/
> Resources/main.py'. See console for errors.'
> 2007-11-11 01:36:53.973 MyApp[1227:10b] Stack: (
> 2420150891,
> 2471022747,
> 2420150347,
> 2420150410
> )
>
> Any thought?
That's a bug in PyObjC. I haven't found the source of the bug yet,
and also don't have a workaround just yet.
Ronald
|
|
From: Chris M. <pyo...@mc...> - 2007-11-11 08:48:17
|
I've looked through the docs, but I can only guess I'm approaching
this the wrong way as I work through Chapter 5 in Hillegass' Cocoa
book via PyOjbc.
If I want to do something that logs all calls to the
respondsToSelector call to my class similar to this:
- (BOOL)respondsToSelector:(SEL)aSelector
{
NSString *methodName = NSStringFromSelector(aSelector);
NSLog(@"respondsToSelector:%@", methodName);
return [super respondsToSelector:aSelector];
}
I would think I would implement something like this in PyObjc:
class MyAppDelegate(NSObject):
def respondsToSelector_(self, aSelector):
NSLog('We Are Responding')
return super(MyAppDelegate,self
).respondsToSelector_(self,aSelector)
However I get a weird error about not being able to create IMP for
instances of objc.native_selector:
Traceback (most recent call last):
File "/Volumes/Raid/mcclimans/MyApp/build/Release/MyApp.app/
Contents/Resources/main.py", line 17, in <module>
import TwiceAsTallAppDelegate
File "/Volumes/Raid/mcclimans/MyApp/build/Release/MyApp.app/
Contents/Resources/MyAppDelegate.py", line 12, in <module>
class TwiceAsTallAppDelegate(NSObject):
TypeError: Error when calling the metaclass bases
Sorry, cannot create IMP for instances of type objc.native_selector
2007-11-11 01:36:53.971 MyApp[1227:10b] *** Terminating app due to
uncaught exception 'NSInternalInconsistencyException', reason: '/
Volumes/Raid/mcclimans/My/main.m:44 main() PyRun_SimpleFile failed
with file '/Volumes/Raid/mcclimans/My/build/Release/MyApp.app/Contents/
Resources/main.py'. See console for errors.'
2007-11-11 01:36:53.973 MyApp[1227:10b] Stack: (
2420150891,
2471022747,
2420150347,
2420150410
)
Any thought?
--
Chris McClimans
|