Format for data exchange between AppleScript & Python?

Hi,

I am currently developing an application, which exports informations only available on our Macintosh computers to our website. Therefor I am using Python scripts to execute AppleScripts via the osascript command [ os.popen("osascript ‘%s’ % applescript) ] and the AppleScripts are returning the grabbed data via the shell in UTF-8. Then the Python scripts are parsing the returned data. Currently I am using a configuration file-like format for this data exchange, an example is given below:

[Application RagTime]
querydate=11.01.2005 09:00:18 (date)
name=RagTime (Unicode text)
version=5.0 (Unicode text)
openwindows=2 (integer)

But this format is being far from perfect. Especially when it comes to the export of nested lists. I know that XML would be a better solution, but XML is quite hard to create without an OSAX (and using an OSAX is no option in my case).

Besides that, I would like to know, how you would implement such a data exchange.

Looking forward to hearing you answers!

Martin

Model: PowerBook 17" 1.33 GHz 1024 MB RAM
AppleScript: 1.10.3
Browser: Safari 417.8
Operating System: Mac OS X (10.4)

Ditch the AppleScripts and use Python for everything; that’ll get rid of the problem completely. See appscript.

Hi hhas,

Thanks for your reply. I had a look at appscript just yesterday evening, when I was seraching Google for the keywords ‘AppleScript Python bridge’. It is definetely cool, but unfortunately I can’t use it, because it needs to be installed on the client computers. But I am searching for a solution, which doesn’t rely on installing a framework, lib or osax. Maybe one should show appscript to Apple, so that they will replace AppleScript with Python scripting, would be so cool :smiley: Only kidding, I love AppleScript, but I hate its longish code and lack of proper dictionaries :rolleyes:

Thanks again!

Martin

P.S.: More and more I have the feeling, that I will have to use XML…

If all you’re worried about is portability, use py2app to package everything up as a single executable. No need to worry about external dependencies being missing or the wrong version because there aren’t any. If you’re not already using it then you really should. It’s great.

has

p.s. If appscript’s LGPL licence is an issue re. including it in a closed-source app then get in touch as I’m changing it to something BSD-like in the next release anyway and will provide permission in the meantime.