예제 #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 call_destination(self, connection, auth_token, user_id, url_or_exten):
        if DestinationFactory.is_destination_url(url_or_exten):
            exten = DestinationFactory.make_from(url_or_exten).to_exten()
        elif caller_id.is_complete_caller_id(url_or_exten):
            exten = caller_id.extract_number(url_or_exten)
        else:
            exten = url_or_exten

        self.call_exten(connection, auth_token, user_id, exten)
예제 #4
0
def normalize_exten(exten):
    try:
        extentodial = caller_id.extract_number(exten)
    except ValueError:
        extentodial = re.sub(VALID_EXTENSION_PATTERN, '', exten)

    if not extentodial:
        raise InvalidExtension(exten)

    return extentodial
예제 #5
0
def normalize_exten(exten):
    try:
        extentodial = caller_id.extract_number(exten)
    except ValueError:
        extentodial = re.sub(VALID_EXTENSION_PATTERN, '', exten)

    if not extentodial:
        raise ValueError('Invalid extension %s', exten)

    return extentodial
예제 #6
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
예제 #7
0
    def test_extract_number_leading_plus(self):
        caller_id = '"User 1" <+1001>'

        ret = extract_number(caller_id)

        self.assertEqual(ret, '+1001')
예제 #8
0
    def test_extract_number(self):
        caller_id = '"User 1" <1001>'

        ret = extract_number(caller_id)

        self.assertEqual(ret, '1001')