[Pythonmac-SIG] PySight

2005-07-13 Thread Dethe Elza
Hi folks,

I'm looking for advice about packaging a library.  Jonathan Wight of  
Toxic Software has built a simple framework around SequenceGrabber to  
expose it to Cocoa.  I've made a trivial PyObjC wrapper and tested it  
sucessfully with Python.  I'd like to build a disk image that  
contains a) an installer for the framework + wrapper, b) sample apps  
(Cocoa and Python versions of the same program), and c) the source  
code to all of these.

Does this sound like a good idea, or should I separate it out into  
multiple .dmg files?

Finally, I haven't really used the bdist_mpkg command to build an  
installer (except for running it on the PyObjC trunk periodically).   
All I'm installing is a framework and an __init__.py file.  Is  
bdist_mpkg the way to go?

TIA

--Dethe

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Unicode Filenames on the Mac

2005-07-13 Thread Bob Ippolito

On Jul 13, 2005, at 6:05 PM, Nick Matsakis wrote:

>
> What is the best way to deal with non-ASCII paths when working with  
> the
> python standard library? Specifically, when using functions like  
> open()
> and the os and glob modules, what should be passed in?  What should I
> expect out?

If you pass unicode in, you get unicode out:

 >>> import os
 >>> set(map(type, os.listdir('.')))
set([])
 >>> set(map(type, os.listdir(u'.')))
set([])

Otherwise you pass and receive byte strings.  The encoding of those  
byte strings is fixed:

 >>> import sys
 >>> sys.getfilesystemencoding()
'utf-8'

> In experimenting with it, it appears that these libraries accept str
> objects containing UTF-8 encoded bytes and similarly that is what they
> return.  It would seem better to me if they could be made to accept  
> and
> return unicode objects, but I could see that that might cause  
> backwards
> compatibility problems.  Still, is UTF-8 encoded strs really a safe  
> bet?
> Are there circumstances, including non HFS filesystems, where it  
> will bite
> me if I make this assumption?

HFS actually uses UTF-16 internally, but the POSIX layer is UTF-8.   
It will bite you if you expect the code to work on other platforms.   
Not all platforms use UTF-8 for their filesystem encoding.

-bob

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] Unicode Filenames on the Mac

2005-07-13 Thread Nick Matsakis

What is the best way to deal with non-ASCII paths when working with the
python standard library? Specifically, when using functions like open()
and the os and glob modules, what should be passed in?  What should I
expect out?

In experimenting with it, it appears that these libraries accept str
objects containing UTF-8 encoded bytes and similarly that is what they
return.  It would seem better to me if they could be made to accept and
return unicode objects, but I could see that that might cause backwards
compatibility problems.  Still, is UTF-8 encoded strs really a safe bet?
Are there circumstances, including non HFS filesystems, where it will bite
me if I make this assumption?

Nick
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] appscript + iPhoto problem

2005-07-13 Thread Gábor Farkas
has wrote:
> Gábor Farkas wrote:
> 
> 

> In general, new elements are created using the 'make' command, so try 
> something like:
> 
> iphoto = appscript.app('iPhoto')
> iphoto.photos[1].keywords.end.make(new=k.keyword, with_properties={k.name: 
> 'some name'})
> 
well, i want to set an already existing keyword, so i did this:

iphoto = appscript.app('iPhoto')
k = iphoto.keywords.get()[-1]
p = iphoto.photos.get()[0]

p.keywords.end.set(k)
this simply waits, and never ends.
when i end it with ctrl+c, i get:


^CTraceback (most recent call last):
   File "", line 1, in ?
   File 
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/appscript/specifier.py",
 
line 203, in __call__
 raise CommandError(self, (args, kargs), e)
appscript.specifier.CommandError: (-1711, 'in AESend, the user cancelled 
out of wait loop for reply or receipt')
 Failed command: 
app(u'/Applications/iPhoto.app').photos.ID(4294967325L).keywords.end.set(app(u'/Applications/iPhoto.app').keywords[u'girl'])



> Can't test that here since I accidentally trashed my copy of iPhoto 2 on my 
> last system reinstall and refuse to pony up $50 for iLife just to replace it. 
> But I reckon it should be close. If not, post back.
> 

hmmm if you got the iPhoto with your computer, then it should be on some 
  of the install cds/dvds..shouldn't it?

gabor
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Zope.Interface won't build on 10.4

2005-07-13 Thread Gary Poster

On Jul 13, 2005, at 1:10 PM, Bob Ippolito wrote:

>
> On Jul 13, 2005, at 4:00 AM, Gary Poster wrote:
>
>
>>
>> On Jul 13, 2005, at 9:55 AM, Kevin Dangoor wrote:
>>
>>
>>
>>> I encountered this as well. I *think* something needs to change  
>>> within
>>> zope.interface to work with gcc 4.x. Anyhow, all you need to do is:
>>>
>>> sudo gcc_select 3.3
>>>
>>> Kevin
>>>
>>>
>>
>> And FWIW I (and others here at Zope Corp) build it just fine on gcc 4
>> with a non-system Python.
>>
>
> You're clearly not using 3.0.1, then, because GCC 4 is rejecting  
> code that's in Zope.Interface.. it has nothing to do with the  
> Python being used.

Ah; good point.  Sorry, yes, we're on the head (and/or Zope 3.1 beta).

Gary
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Zope.Interface won't build on 10.4

2005-07-13 Thread Bob Ippolito

On Jul 13, 2005, at 4:00 AM, Gary Poster wrote:

>
> On Jul 13, 2005, at 9:55 AM, Kevin Dangoor wrote:
>
>
>> I encountered this as well. I *think* something needs to change  
>> within
>> zope.interface to work with gcc 4.x. Anyhow, all you need to do is:
>>
>> sudo gcc_select 3.3
>>
>> Kevin
>>
>
> And FWIW I (and others here at Zope Corp) build it just fine on gcc 4
> with a non-system Python.

You're clearly not using 3.0.1, then, because GCC 4 is rejecting code  
that's in Zope.Interface.. it has nothing to do with the Python being  
used.

The easiest way to install Zope.Interface is just to get the ones  
that I built on 10.3: http://pythonmac.org/packages/

-bob

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Zope.Interface won't build on 10.4

2005-07-13 Thread brad . allen

Kevin Dangoor <[EMAIL PROTECTED]> wrote on 07/13/2005
08:55:47 AM:

> I encountered this as well. I *think* something needs to change within
> zope.interface to work with gcc 4.x. Anyhow, all you need to do is:
> 
> sudo gcc_select 3.3

Thanks! That worked.___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Zope.Interface won't build on 10.4

2005-07-13 Thread Gary Poster

On Jul 13, 2005, at 9:55 AM, Kevin Dangoor wrote:

> I encountered this as well. I *think* something needs to change within
> zope.interface to work with gcc 4.x. Anyhow, all you need to do is:
>
> sudo gcc_select 3.3
>
> Kevin

And FWIW I (and others here at Zope Corp) build it just fine on gcc 4  
with a non-system Python.

Gary
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Zope.Interface won't build on 10.4

2005-07-13 Thread Kevin Dangoor
I encountered this as well. I *think* something needs to change within
zope.interface to work with gcc 4.x. Anyhow, all you need to do is:

sudo gcc_select 3.3

Kevin

On 7/13/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>  
> Maybe I should take this to one of  the Twisted or Zope lists, but this
> appears to be a Mac-specific issue so I thought it worth mentioning here.
> The problem is that Zope Interface 3.01 won't build on Mac OS 10.3 using
> either the stock Python 2.3 or Python 2.4.1 (error transcript at the
> bottom). 
>  
>  A Google search of the problem turned up a discussion on one of the Zope
> lists about this, but I didn't understand how to implement the suggested
> solution.  One message in the thread suggests the problem is that Python was
> compiled under gcc 3.x and Mac OS 10.4 defaults to using gcc 4.x, and that
> using gcc select can fix the problem. Any thoughts on how to do that?
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] Zope.Interface won't build on 10.4

2005-07-13 Thread brad . allen

Maybe I should take this to one of  the
Twisted or Zope lists, but this appears to be a Mac-specific issue so I
thought it worth mentioning here. The problem is that Zope Interface 3.01
won't build on Mac OS 10.3 using either the stock Python 2.3 or Python
2.4.1 (error transcript at the bottom).

 A Google search of the problem
turned up a discussion on one of the Zope lists about this, but I didn't
understand how to implement the suggested solution.  One message in
the thread suggests the problem is that Python was compiled under gcc 3.x
and Mac OS 10.4 defaults to using gcc 4.x, and that using gcc select can
fix the problem. Any thoughts on how to do that?

http://mail.zope.org/pipermail/zope3-users/2005-June/000725.html

Here is the error transcript. A similar
error happens when running setup.py install.

oms-ballen:~/Desktop/TwistedSumo-2005-05-25/ZopeInterface-3.0.1
ballen$ sudo python setup.py build
Password:
running build
running build_py
running build_ext
building 'zope.interface._zope_interface_coptimizations'
extension
gcc -fno-strict-aliasing -Wno-long-double
-no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -IDependencies/zope.interface-ZopeInterface-3.0.1/zope.interface
-I/System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3
-c Dependencies/zope.interface-ZopeInterface-3.0.1/zope.interface/_zope_interface_coptimizations.c
-o build/temp.darwin-8.1.0-Power_Macintosh-2.3/Dependencies/zope.interface-ZopeInterface-3.0.1/zope.interface/_zope_interface_coptimizations.o
Dependencies/zope.interface-ZopeInterface-3.0.1/zope.interface/_zope_interface_coptimizations.c:339:
error: static declaration of 'SpecType' follows non-static declaration
Dependencies/zope.interface-ZopeInterface-3.0.1/zope.interface/_zope_interface_coptimizations.c:73:
error: previous declaration of 'SpecType' was here
error: command 'gcc' failed with exit
status 1     ___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] appscript + iPhoto problem

2005-07-13 Thread has
Gábor Farkas wrote:

>>what i want to achieve is the following.
>>
>>i want to find a photo in iphoto (i can do that),
>>and then assign some keywords to it.
>[...]
>ok, now i know more ;)
>
>i can use:
>
>iphoto = appscript.app('iPhoto')
>photos = iphoto.photos.get()
>photo = photos[0]
>photo.title.set('newTitle')

Simpler:

iphoto = appscript.app('iPhoto')
iphoto.photos[1].title.set('newTitle')


>and this works.
>
>my other problem now is the keywords...
>
>which seems to be an array...

Actually a one-to-many relationship, called 'elements' in appscript/AppleScript 
jargon.

OK, quick summary since I've not finished writing this stuff up properly yet:

Mac application scripting is based on procedural RPC + relational queries. 
Appscript and AppleScript tend to obfuscate this mechanism under OO-like 
syntactic sugar, but don't let this fool you. The syntax is merely there to 
make it nicer to use; you'll see a similar sort of approach used in SQLObject.

Basically what you do is construct a query identifying the object or objects 
you want to manipulate, then send a command to that application with that query 
as [usually] its direct parameter. The application evaluates that query against 
its Apple Event Object Model, finds the object(s) to manipulate and performs 
the appropriate action on it/them.

The application's dictionary, which you can view with htmldoc or the built-in 
help() system, [inadequately] documents the application's AEOM and all the 
commands the application can respond to. There are various classes of object 
comprising the AEOM, with the root node being the 'application' object. Every 
object may have zero or more attributes (e.g. name, class, size, bounds, etc. 
properties), zero or more one-to-one relationships (e.g. Finder's home 
property, iTunes' current_album and current_track properties), and zero or more 
one-to-many relationships (e.g. Finder's items, containers, disks, folders, 
etc. elements).

Attributes usually contain simple values (strings, numbers, etc.) describing an 
object (e.g. its name, size, position or colour). One-to-many relationships 
usually (but not always) reflect the objects' containment structure (e.g. a 
Finder folder object can contain any number of folder, alias_file, 
application_file, document_file, etc. objects). One-to-one relationships often 
provide shortcuts to objects of special interest (e.g. iTunes' currently 
playing track).


The appscript documentation will keep you right on legal syntactic forms, 
special cases, etc., so make sure you read that too.


>i tried to simply get it's keywords, append a new keyword to the array, and 
>set it, but it did not work:

Hopefully the above makes clear why array manipulation doesn't (and can't) work.


>i get an "Application error 8 (NSInternalScriptError)"

Cocoa apps tend to provide spectacularly bad error messages. (Feel free to file 
lots of irritatedly impatient feature requests on this.) This is one of those 
areas where most application's documentation is sorely inadequate, and you have 
to resort to educated guesswork based on general knowledge of how the AEOM 
works. In general, new elements are created using the 'make' command, so try 
something like:

iphoto = appscript.app('iPhoto')
iphoto.photos[1].keywords.end.make(new=k.keyword, with_properties={k.name: 
'some name'})

Can't test that here since I accidentally trashed my copy of iPhoto 2 on my 
last system reinstall and refuse to pony up $50 for iLife just to replace it. 
But I reckon it should be close. If not, post back.

HTH

has
-- 
http://freespace.virgin.net/hamish.sanderson/
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] appscript + iPhoto problem

2005-07-13 Thread gabor
Gábor Farkas wrote:
> hi,
> 
> what i want to achieve is the following.
> 
> i want to find a photo in iphoto (i can do that),
> and then assign some keywords to it.
> 
> i can find the photo with:
> 
> iphoto = appscript.app('iPhoto')
> photos = iphoto.photos()
> 
> and then i find my photo in 'photos'.
> 
> and i can also list it's keywords.
> but how should i SET the keywords?
> 
> i tried to call the 'help()' method on those objects,
> but all i get are properties, and i can't find a way to set them.
> 
ok, now i know more ;)

i can use:

iphoto = appscript.app('iPhoto')
photos = iphoto.photos.get()
photo = photos[0]
photo.title.set('newTitle')

and this works.

my other problem now is the keywords...

which seems to be an array... how do you work with an array-property in 
appscript?

i tried to simply get it's keywords, append a new keyword to the array, 
and set it, but it did not work:

keys = photo.keywords.get()
allkeys = iphoto.keywords.get()
lastkey = allkeys[-1]

keys.append(lastkey)
photo.keywords.set(keys)

i get an "Application error 8 (NSInternalScriptError)"

:(

gabor



___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig