growlnotifyの謎とpythonインターフェイス

growlnotifyの挙動不審

なぜかgrowlnotifyにimageオプションを渡すとNotifyが出る時とでない時がある.

結局よくわからん.

というわけでPythonから呼び出すインターフェイスを利用してみる.

Growl SKD - Python Interface

GrowlPythonコードから直接呼び出すために GrowlSDKを試してみた.

まずここからSKDをダウンロードする.

でイメージをマウントして,中身の'Growl *** SKD/Bindings/python'を適当なところに移してインストール.

$ cd '/Volumes/Grow 1.1.4 SDK/Bindings'
$ cp -r python ~/Desktop/
$ cd ~/Desktop/python
$ sudo python setup.py install
running install
running build
running build_py
running build_ext
building '_growlImage' extension
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-i386-2.6/growlImage.o -o build/lib.macosx-10.3-i386-2.6/_growlImage.so -framework Cocoa
ld: in /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libJPEG.dylib, file is not of required architecture for architecture ppc
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccmnkjnb.out (No such file or directory)
error: command 'gcc' failed with exit status 1

うへなんかエラーが出てる.

なんかよくわらんけど,'gcc -arch...'の'-arch ppc'が怪しいので消す.

で無理やりコンパイル

$ sudo python setup.py install
running install
running build
running build_py
copying Growl.py -> build/lib.macosx-10.3-i386-2.6
running build_ext
running install_lib
copying build/lib.macosx-10.3-i386-2.6/Growl.py -> /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
byte-compiling /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Growl.py to Growl.pyc
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Growl.py:176: SyntaxWarning: assertion is always true, perhaps remove parentheses?
assert(self.applicationName, 'An application name is required.')
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Growl.py:180: SyntaxWarning: assertion is always true, perhaps remove parentheses?
assert(self.notifications, 'A sequence of one or more notification names is required.')
running install_egg_info
Removing /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py_Growl-0.0.7-py2.6.egg-info
Writing /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py_Growl-0.0.7-py2.6.egg-info

うーん,assertが残ってるwwwきもす.というわけで'-DNDEBUG'

$ sudo gcc -DNDEBUG -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-i386-2.6/growlImage.o -o build/lib.macosx-10.3-i386-2.6/_growlImage.so -framework Cocoa
$ sudo python setup.py install

で走らせてみる

$ python
>>> import Growl
Growl.py:17: DeprecationWarning: the md5 module is deprecated; use hashlib instead
import md5

うへ,こんどはモジュールね.

ちょっと調べてみたらmd5はhashlibからインポートすることに(2.5ではWarning, 3.0ではダメ)になったようです.

Growl.pyの17行目を

from hashlib import md5

としておく.

で,もう一回インストールからやり直しw

これで入るはず.

参考文献