self.output.put('More than one account exists which matches %s: %s\n'%(self.options.account,', '.join(sorted(account.idforaccountinpossible_accounts))))
self.output.stop()
self.stop()
return
eliflen(possible_accounts)==0:
self.output.put('No enabled account which matches %s was found. Available and enabled accounts: %s\n'%(self.options.account,', '.join(sorted(account.idforaccountinaccount_manager.get_accounts()ifaccount.enabled))))
self.output.put('Listening on: sip:%s@%s:%d;transport=%s\n'%(contact.user,contact.host,contact.port,contact.parameters['transport']if'transport'incontact.parameterselse'udp'))
message='%s Registered contact "%s" for sip:%s at %s:%d;transport=%s (expires in %d seconds).\n'%(datetime.now().replace(microsecond=0),notification.data.contact_header.uri,self.account.id,route.address,route.port,route.transport,notification.data.expires)
self.output.put('%s Failed to register contact for sip:%s at %s:%d;transport=%s: %s. %s\n'%(datetime.now().replace(microsecond=0),self.account.id,route.address,route.port,route.transport,status_text,next_route_text))
else:
self.output.put('%s Failed to register contact for sip:%s: %s\n'%(datetime.now().replace(microsecond=0),self.account.id,notification.data.reason))
self.output.put('No more routes to try. Aborting.\n')
self.stop()
if__name__=='__main__':
description="This will either sit idle waiting for an incoming MESSAGE request, or send a MESSAGE request to the specified SIP target. In outgoing mode the program will read the contents of the messages to be sent from standard input, Ctrl+D signalling EOF as usual. In listen mode the program will quit when Ctrl+D is pressed."
parser.add_option('-a','--account',type='string',dest='account',help='The account name to use for any outgoing traffic. If not supplied, the default account will be used.',metavar='NAME')
parser.add_option('-c','--config-file',type='string',dest='config_file',help='The path to a configuration file to use. This overrides the default location of the configuration file.',metavar='FILE')
parser.add_option('-s','--trace-sip',action='store_true',dest='trace_sip',default=False,help='Dump the raw contents of incoming and outgoing SIP messages.')
parser.add_option('-n','--trace-notifications',action='store_true',dest='trace_notifications',default=False,help='Print all notifications (disabled by default).')
parser.add_option('-b','--batch',action='store_true',dest='batch_mode',default=False,help='Run the program in batch mode: reading control input from the console is disabled. This is particularly useful when running this script in a non-interactive environment.')
parser.add_option('-m','--message',type='string',dest='message',help='Contents of the message to send. This disables reading the message from standard input.')