Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Using select.kqueue to monitor garageband transcode completion

Reply
Thread Tools

Using select.kqueue to monitor garageband transcode completion

 
 
harijay
Guest
Posts: n/a
 
      01-25-2011
I want to automate a series of functions in python that trigger when
the OSX application Garagband finishes writing to a file called
"todays_recording.mp3".

A Typical transcode process takes 20 minutes , and I fancy starting
the python program immediately after I start the transcode and then
walking away.

For the present moment I have a silly implementation that does
something like the code pasted below.

I was looking online for smarter I/O monitoring and I came across the
kqueue classes inside of the select module which could be used to
monitor the kernel events in BSD - so it should work on OSX. However
being a newbie , I cannot understand how to setup the select.kqueue
event to look for garageband closing , i.e finish writing the
transcoded mp3 file.

I did see some code on comp.lang.python about this in a post from
Ritesh Nadhani (pasted below as well). But I dont understand what the
events mean . Looking for help to monitor the file closing using
select.kqueue.


Thanks
Hari



My Pseudocode for clunky monitoring of file i/o completion:

while True:
try:
today_file = open("todays_recording.mp3","r")
my_custom_function_to_process_file(today_file)
except IOError:
print "File not ready yet..continuing to wait"

###############
Some source code I came across on comp.lang.python ( courtesy Ritesh
Vadvani) related to this
##############

import select26 as select
import os

kq = select.kqueue()
fd = os.open("/tmp/a.txt", os.O_RDONLY)

# I dont understand this line below
ev = [select.kevent(fd, filter=select.KQ_FILTER_VNODE,
flags=select.KQ_EV_ADD | select.KQ_EV_ENABLE | select.KQ_EV_ONESHOT,
fflags=select.KQ_NOTE_WRITE | select.KQ_NOTE_DELETE
| select.KQ_NOTE_EXTEND)]
kq.control(ev, 0, 0)

try:
while True:
evts = kq.control(ev, 1, None)
if len(evts):
print evts
except KeyboardInterrupt:
pass
else:
kq.close()
os.close(fd)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Plug-ins are not showing up in Garageband??? Tom Computer Support 1 01-07-2007 06:37 AM
XML transcode - CString to XMLCh eagle_speaks@yahoo.co.uk XML 0 08-16-2005 10:12 AM
Transcode Japanese?? Robert M. Gary XML 2 04-19-2005 01:56 PM
Leaks in XMLString::transcode Prajakta XML 0 04-22-2004 01:51 PM
Spelling Completion or Code completion in ASP? ziggs ASP General 2 04-21-2004 02:02 PM



Advertisments