Thanks for the answers Ned.

Regards,

Raj

On Mon, Sep 15, 2008 at 10:42 PM, Ned Deily <[EMAIL PROTECTED]> wrote:
> In article
> <[EMAIL PROTECTED]>,
>  "Rajanikanth Jammalamadaka" <[EMAIL PROTECTED]> wrote:
>
>> Could somebody please tell me why I get this error?
>>
>> >>> import findertools
>> >>> findertools.sleep()
> [...]
>
> The simple answer is: don't use findertools, or most other MacPython
> modules for that matter.  They were written for classic MacOS, aren't
> really supported anymore under OS X, and are being removed in future
> versions of Python.
>
> You're on the right track by using appscript.
>
>> >>> from appscript import *
>> >>> app(u'Finder').sleep()
>>
>> Traceback (most recent call last):
>>   File "<pyshell#3>", line 1, in <module>
>>     app(u'Finder').sleep()
>>   File
>>   
>> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packag
>>   es/appscript-0.18.1-py2.5-macosx-10.5-i386.egg/appscript/reference.py",
>> line 439, in __call__
>>     raise CommandError(self, (args, kargs), e)
>> CommandError: CommandError -1708: Application could not handle this command.
>>       Failed command: app(u'/System/Library/CoreServices/Finder.app').sleep()
>> >>> app(u'Finder').sleep()
>>
>> Traceback (most recent call last):
>>   File "<pyshell#4>", line 1, in <module>
>>     app(u'Finder').sleep()
>>   File
>>   
>> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packag
>>   es/appscript-0.18.1-py2.5-macosx-10.5-i386.egg/appscript/reference.py",
>> line 439, in __call__
>>     raise CommandError(self, (args, kargs), e)
>> CommandError: CommandError -1708: Application could not handle this command.
>>       Failed command: app(u'/System/Library/CoreServices/Finder.app').sleep()
>
> The problem here is that "sleep" and various other commands. which were
> a part of the Finder in classic MacOS, are now - under the covers -
> implemented by other services in OS X.  In particular, 'sleep' and other
> power events are scripted through the "System Events" agent.
>
>>>> from appscript import *
>>>> app('System Events').sleep()
>
> You can browse its terminology using, for example, appscript's built-in
> help introspection or Apple's Script Editor.
>
>> Also, what would be the best way to mount a .dmg file using appscript?
>
> One simple way is to just pass the path of the .dmg file to System
> Event's open:
>
>>>> app('System Events').open('/Users/nad/blah.dmg')
>
> If that's too simple-minded, you could wrap a shell call to hdiutil(1).
>
> --
>  Ned Deily,
>  [EMAIL PROTECTED]
>
> _______________________________________________
> Pythonmac-SIG maillist  -  [email protected]
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>



-- 
Rajanikanth
_______________________________________________
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to