[Freeswitch-users] Use of callback functions in Python causing os.stat() to stop working?
Marc Orenberg
marc at kasteris.com
Wed Oct 22 13:19:39 PDT 2008
Hello,
In FreeSwitch 1.0.1 using Python, I'm having a strange problem with callback functions.
When I define a callback function, for some reason I'm unable to use any of the os.stat() related functions in Python.
The example below shows the problem. When it runs, I get the following error:
return os.stat(filename).st_size
TypeError: expected string or Unicode object, NoneType found
I know that I'm passing a correct value into the stat function.
But if I comment-out my call to the callback function, it executes fine.
I'm sure there's some larger issue going on here, but I'm not sure where to look.
import os
from freeswitch import *
def input_callback_record_file_pound_stop(session, what, obj):
if (type == "dtmf" and obj['digit'] == '#'):
return "break"
def input_callback_normal(session,what,obj):
consoleLog("INFO", "input_callback_normal")
def record_file(session,filename):
session.streamFile("/usr/local/acudoc/prompts/shortbeeptone.wav")
session.setInputCallback(input_callback_record_file_pound_stop)
ret = session.recordFile(filename, 60000, 3, 3)
session.setInputCallback(input_callback_normal)
return(ret)
def handler(session, args):
session.answer()
session.execute("sleep", "1000")
record_file(session,"/home/marc/test.wav")
thesize = os.path.getsize("/home/marc/test.wav")
consoleLog("INFO","Size = " + str(thesize) + "\n")
Thanks,
Marc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20081022/83eac6d4/attachment-0002.html
More information about the FreeSWITCH-users
mailing list