[Pythonmac-SIG] appscript path issue

Bill Janssen janssen at parc.com
Thu Mar 5 19:55:18 CET 2009


has <hengist.podd at virgin.net> wrote:

> Bill Janssen wrote:
> 
> > I'm trying to write this scrap of Applescript in Python appscript:
> >
> >  on run
> > 	tell application "Microsoft PowerPoint"
> > 		set this_item to path of active presentation
> > 	end tell
> > 	set unix_item to POSIX path of this_item
> > 	display dialog of unix_item
> >  end run
> >
> > which yields "/tilde/janssen/Documents", an NFS-mounted location.
> 
> Is that correct? Shouldn't the volume appear under /Volumes? Is the
> volume identified by this path mounted at the time you run this code?
> If not, try it and see what happens.

Yes, it's correct, and yes, the volume is mounted -- the code is running
out of it, in fact.  It's my home directory.  The automounter mounts
these NFS shares automatically under "/tilde" if they come from the
"mount.byname" YP map.  They don't show up under /Volumes at all.

> Appscript uses CFURL functions to convert POSIX to HFS paths and vice-
> versa. (I'd have thought AS would use the same functions, but maybe
> not.) The relevant code is in the ae.c file for your reference.

Yes, I found it.  I've been playing around with that code using
Carbon.File...  I was kind of hoping that this would do it

Carbon.File.FSMakeFSSpec(0, 0, "janssen:Documents").FSpMakeFSRef().as_pathname()

but not so -- maybe that's the same bug that shows up in
CFURLCreateWithFilesystemPath.  I think what one has to do is to
enumerate the volumes, identify the one labelled as "janssen", and then
use that volume ID as the parent to

Carbon.File.FSMakeFSSpec(volumeID, 0, "Documents").FSpMakeFSRef().as_pathname()

(I think enumeration is necessary -- at least, I don't see any call
that says, "give me the volumeID of the volume known as 'janssen'".)

> If you
> find a problem in the way that HFS<->POSIX paths are converted, I'd
> suggest writing up a test case in C to confirm the same behaviour
> there, then submit a bug report to Apple on it as its their APIs that
> are responsible for it.

Sure.  But I'm guessing that they don't actually use
CFURLCreateWithFilesystemPath...  And until the bug is fixed, I'd like
to find a workaround for appscript to use.

Sure like to know how "POSIX path of" does it...

Bill


More information about the Pythonmac-SIG mailing list