示例#1
0
 def _get_cid_name_and_number_from_line(self, line):
     try:
         cid_name = caller_id.extract_displayname(line['callerid'])
         cid_num = caller_id.extract_number(line['callerid'])
     except ValueError:
         cid_name = ''
         cid_num = ''
     return cid_name, cid_num
示例#2
0
 def _get_cid_name_and_number_from_line(self, line):
     try:
         cid_name = caller_id.extract_displayname(line['callerid'])
         cid_num = caller_id.extract_number(line['callerid'])
     except ValueError:
         cid_name = ''
         cid_num = ''
     return cid_name, cid_num
示例#3
0
 def _parse_callerid(value, result):
     value = value.decode('utf-8')
     if value == 'Unknown':
         result['caller_id_name'] = None
         result['caller_id_num'] = None
     elif caller_id.is_complete_caller_id(value):
         result['caller_id_name'] = caller_id.extract_displayname(value)
         result['caller_id_num'] = caller_id.extract_number(value)
     else:
         result['caller_id_name'] = None
         result['caller_id_num'] = value
示例#4
0
def populate_sip_line(config, confregistrar, line, extension):
    provd_config_manager = provd_connector.config_manager()
    if 'sip_lines' not in config['raw_config']:
        config['raw_config']['sip_lines'] = dict()
    config['raw_config']['sip_lines'][str(line.device_slot)] = dict()
    line_dict = config['raw_config']['sip_lines'][str(line.device_slot)]
    line_dict['auth_username'] = line.name
    line_dict['username'] = line.name
    line_dict['password'] = line.secret
    line_dict['display_name'] = caller_id.extract_displayname(line.callerid)
    line_dict['number'] = extension.exten
    line_dict['registrar_ip'] = confregistrar['registrar_main']
    line_dict['proxy_ip'] = confregistrar['proxy_main']
    if 'proxy_backup' in confregistrar and len(confregistrar['proxy_backup']) > 0:
        line_dict['backup_registrar_ip'] = confregistrar['registrar_backup']
        line_dict['backup_proxy_ip'] = confregistrar['proxy_backup']
    provd_config_manager.update(config)
示例#5
0
def populate_sip_line(config, confregistrar, line, extension):
    provd_config_manager = provd_connector.config_manager()
    if 'sip_lines' not in config['raw_config']:
        config['raw_config']['sip_lines'] = dict()
    config['raw_config']['sip_lines'][str(line.device_slot)] = dict()
    line_dict = config['raw_config']['sip_lines'][str(line.device_slot)]
    line_dict['auth_username'] = line.name
    line_dict['username'] = line.name
    line_dict['password'] = line.secret
    line_dict['display_name'] = caller_id.extract_displayname(line.callerid)
    line_dict['number'] = extension.exten
    line_dict['registrar_ip'] = confregistrar['registrar_main']
    line_dict['proxy_ip'] = confregistrar['proxy_main']
    if 'proxy_backup' in confregistrar and len(
            confregistrar['proxy_backup']) > 0:
        line_dict['backup_registrar_ip'] = confregistrar['registrar_backup']
        line_dict['backup_proxy_ip'] = confregistrar['proxy_backup']
    provd_config_manager.update(config)
示例#6
0
    def test_extract_displayname(self):
        caller_id = '"User 1" <1001>'

        ret = extract_displayname(caller_id)

        self.assertEqual(ret, 'User 1')