Re: [Pythonmac-SIG] appscript path issue
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. I'm not an expert on Unix mounting points, but my impression is that that is where they normally go. I've also noticed that HFS-POSIX path conversions only produce a path beginning with /Volumes when the volume is mounted. I suspect the result given when the volume isn't mounted is wrong/undefined, but as I say I'm no expert in this area. I've got this: from appscript import * from mactypes import * print File.makewithhfspath(app(Microsoft PowerPoint).active_presentation.path()).path However, in this case, I get /janssen/Documents, which is wrong. 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. 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. HTH has -- Control AppleScriptable applications from Python, Ruby and ObjC: http://appscript.sourceforge.net ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] appscript path issue
has hengist.p...@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 ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] appscript path issue
I wouldn't be surprised if the root of the problem is with PowerPoint. It started its life as an OS9 application, so if it still thinks it lives in an OS9 world with FSSpecs and colon-separated pathnames, it could be trying to do the conversion to posix paths itself. And such a conversion might well fail for hand-mounted NFS shares in non-standard locations... -- Jack Jansen, jack.jan...@cwi.nl, http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig