""" This is an inbound application that rings the call for 2 seconds, answers the call, then reads out the following text:: "Welcome to your U.A.S application." "The voice you are hearing has been commanded by your machine." "The hostname of the machine is ." "The application parameter supplied to the application is . Goodbye." """ __uas_identify__ = "application" __uas_version__ = "1.0b3" import sys, os, socket from prosody.uas import Hangup, Error def main(channel, application_instance_id, file_man, my_log, application_parameters): log_pref = "quickstart:" call_to = channel.Details.call_to my_log.info("{0} started with call_to [{1}]".format(log_pref, call_to)) #grab the machine hostname hostname = socket.gethostname() # Our default text for the application_parameters are "Nothing", which is replaced if there's any text to play test_args = "Nothing" if application_parameters != "": test_args = application_parameters # The main program try: # ring for two seconds channel.ring(2) # answer the call channel.answer() # say some text. The text is converted to speech using an inbuilt Text-To-Speech (TTS) converter channel.FilePlayer.say("Welcome to your U.A.S application. \ The voice you are hearing has been commanded by your machine. \ The hostname of the machine is {0}. \ The application parameters supplied to the application are {1}. Goodbye.".format(hostname, test_args)) # Hang up the call! channel.hang_up() except Hangup as exc: my_log.info("{0} completed with Hangup".format(log_pref)) except Error as exc: my_log.error("{0} completed with Error exception! {1}".format(log_pref, exc)) return -101 except Exception as exc: my_log.exception("{0} completed with exception! {1}".format(log_pref, exc)) return -102 my_log.info("{0} completed".format(log_pref)) return 0