[Pythonmac-SIG] appscript and quicktime
Frank Hoffsümmer
frank.hoffsummer at gmx.de
Fri Oct 7 20:29:03 CEST 2005
Nicholas, Has,
thanks a lot for bringing me up to speed!
the help functions didnt all work for me, and I completely missed
htmldoc.py, so I was flying blind....
e.g. quicktime.can_export.help() results in errors for me (using
apples tiger pythonw)
========================================================================
========
Appscript Help (-t)
Reference: app(u'/Applications/QuickTime Player.app').can_export
------------------------------------------------------------------------
--------
Description of reference
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/appscript/helpmixins.py", line 47, in help
return self._appData.help(flags, self)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/appscript/helpmixins.py", line 41, in <lambda>
self.help = lambda flags, ref: helpObj.help(flags, ref) #
replace stub method with real help
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/appscript/helpsystem.py", line 361, in help
wrapper = fn(self, *args)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/appscript/helpsystem.py", line 269, in
_terminologyForClassOrCommand
ref.AS_printTerminologyForThisRef(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/appscript/helpmixins.py", line 56, in
AS_printTerminologyForThisRef
helpObj.command(self._classcode, self._idcode)
AttributeError: 'Command' object has no attribute '_classcode'
but now, thanks to htmldoc.py, I have the full quicktime help anyway
thanks again!
-frank
On 5 okt 2005, at 19.36, has wrote:
> captnswing wrote:
>
>
>> the following applescript snippet seems unimplementable in
>> appscript, to me at least:
>>
>> =================================================
>> if (can export movie 1 as DV stream) is true then
>> try
>> with timeout of 360 seconds
>> export movie 1 to POSIX file the_newname as DV stream
>> using settings the_settings with replacing
>> end timeout
>> on error errorMsg number errNo
>> ...
>> end try
>> end if
>> =================================================
>>
>
>
> #!/usr/bin/env pythonw
>
> from appscript import *
> from macfile import File
>
> qtp = app('QuickTime Player')
>
> m = qtp.movies[1]
> if m.can_export(as=k.DV_stream):
> try:
> m.export(to=File(the_newname), as=k.DV_stream,
> using_settings=the_settings, replacing=True,
> timeout=360)
> except Exception, e:
> ...
>
>
>
>> =================================================
>> --get number of tracks and kind of movie
>> tell application "QuickTime Player"
>> activate
>> open the_file
>> tell movie file_name
>> set track_count to the count of tracks
>> set track_kind to the kind of track 1
>> end tell
>> end tell
>>
>> --if movie is muxed mpeg
>> if (track_count is equal to 1) and (track_kind contains "Muxed") then
>> .....
>> =================================================
>>
>
> qtp.activate()
> qtp.open(the_file)
> m = qtp.movies[file_name]
> track_count = m.tracks.count()
> track_kind = m.tracks[1].kind.get()
>
> if track_count == 1 and 'Muxed' in track_kind:
> ...
>
>
>
>> it is unclear to me how to get to the track_kind property of a movie
>> are not all properties and functions mapped over to appscript?
>>
>
> Everything maps (barring bugs). As Nick says, use appscript's help
> system for viewing applications' dictionaries; it's pretty
> extensive (roughly on par with Script Debugger's dictionary tools,
> though CLI-based rather than GUI).
>
>
>
>> also I wonder how you can tell which appscript command takes what
>> parameters.
>>
>
> See the appscript documentation for info on appscript-defined
> parameters (e.g. 'timeout'), and use the help system to view the
> command's basic definition. The rest is searching secondary
> resources (supplementary documentation, sample scripts, mailing
> list discussions, etc.), educated guesswork and trial and error,
> same as usual. Application dictionaries have always been
> frustratingly vague on the finer details; appscript only saves you
> from the AppleScript language, not the shortcomings of individual
> applications.
>
>
>
>> and finally, what does the k. in the documentation
>>
>
> 'Keyword'. It's a fake namespace, part of appscript's syntactic
> sugar, used to specify types and enumerations.
>
>
>
>> (and the above get () call) stand for?
>>
>
> Unlike AppleScript, which can perform 'implicit gets' when
> evaluating a literal application reference, appscript only sends a
> get event when you tell it to. Again, this is in the appscript
> documentation.
>
> HTH
>
> has
> --
> http://freespace.virgin.net/hamish.sanderson/
> _______________________________________________
> Pythonmac-SIG maillist - Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>
>
>
More information about the Pythonmac-SIG
mailing list