[Pythonmac-SIG] Okay folks--show me how and I'll write it up...
Jack Jansen
Jack.Jansen@oratrix.com
Thu, 28 Nov 2002 11:27:09 +0100
On woensdag, nov 27, 2002, at 22:36 Europe/Amsterdam, Daniel Lord wrote:
> Here is an example of what we'd all like to see from the Mac Python
> Community (those Perl folks are way ahead of us):
>
> http://www.macdevcenter.com/pub/a/mac/2002/11/22/itunes_perl.html
>
> And, as the saying goes, if you want it done--do it yourself. Okay I
> will--I have the time to learn and document and I will. But..
> I need some help and pointers first:
> 1) I have a framework install of Python-2.2.2 and AquaTk on 10.2.1 but
> I get simple errors even after hand-copying the Mac/Lib modules
> (including lib-scriptpackages) See ERROR 1 below for an example.
>
> 2) osam looks interesting but...the project file is corrupted so I
> don't have a template of what to include to build it. Any docs any
> where?
Osam is really a stopgap. The preferred way to control OSA applications
from Python is to use the fullblown OSA interface, this gives you
complete access to all features from Python, in a "pythonic" way.
Unfortunately you first have to create the interface module for the
specific program you want to control. This is done with
Mac/scripts/gensuitemodule.py. For some common applications the suites
are pre-generated, you'll find these in Mac/Lib/lib-scriptpackages.
There is some minimal documentation, see Mac/Demo/applescript.html.
>
> 3) Is any of this fixed in 2.3a0--I retrieved it from CVS yesterday
> but hesitate to install it and ruin my framework install or,
> worse yet, pester you all with defects I induced by doing that.
Actually, I would guess that the mac-specific stuff in 2.3a0 may well
be more stable than that in 2.2.X.
> 4) Jack wrote message about installing MacPython innocuously over a
> framework install. Before I do this, does it work for 2.3a0?
If you mean "MacPython 2.2.X", i.e. the version that also runs on OS9:
this version is indeed 100% separate from either the framework or
non-framework unix-install.
> 5) any other docs, examples, etc. on how to use Applescript with
> Python--send me a pointer please.
Apart from the things mentioned above, also look at
Mac/Lib/findertools, or Mac/Lib/mkcwproject for examples that use the
OSA stuff.
> ERROR 1
> ========
> [anduril:~/Learning/python/Applescript] daniello% pythonw
> codewarrior1.py
> original argc=2
> original argv[0] = "/Applications/Python.app/Contents/MacOS/python"
> original argv[1] = "codewarrior1.py"
> modified argc=2
> modified argv[0] = "/Applications/Python.app/Contents/MacOS/python"
> modified argv[1] = "codewarrior1.py"
> running sitecustomize.py
> Traceback (most recent call last):
> File "codewarrior1.py", line 1, in ?
> import CodeWarrior
> File
> "/Library/Frameworks/Python.framework/Versions/2.2/lib/python2.2/site-
> packages/CodeWarrior/__init__.py", line 5, in ?
> import aetools
> File
> "/Library/Frameworks/Python.framework/Versions/2.2/lib/python2.2/site-
> packages/aetools.py", line 31, in ?
> from aepack import pack, unpack, coerce, AEDescType
> File
> "/Library/Frameworks/Python.framework/Versions/2.2/lib/python2.2/site-
> packages/aepack.py", line 61, in ?
> _sample_fss = macfs.FSSpec(':')
> MacOS.Error: (-43, 'File not found')
That's a bug that's fixed in 2.3a0. The quick workaround is to change
the ':' to os.curdir.
If you want this fixed in 2.2.3 please submit a sourceforge bugreport
so I won't forget.
--
- Jack Jansen <Jack.Jansen@oratrix.com>
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma
Goldman -