def list(req):
    req.content_type = 'application/json; charset=UTF8'

    try:
        return json.dumps({ 'Result': 'OK', 'Records': config.list_speeddial_numbers() })
    except Exception, e:
        return json.dumps({ 'Result': 'ERROR', 'Message': str(e) })
def _check_shortcut(shortcut):
    if (re.match("^[0-9#\*]{1,3}$", shortcut) == None):
        raise Exception('Invalid speed dial number')

    for number in config.list_speeddial_numbers():
        if (number['shortcut'] == shortcut):
            raise Exception('Speed dial number already exists!')
def _check_shortcut(shortcut):
    if (re.match("^[0-9#\*]{1,3}$", shortcut) == None):
        raise Exception('Invalid speed dial number')

    for number in config.list_speeddial_numbers():
        if (number['shortcut'] == shortcut):
            raise Exception('Speed dial number already exists!')
def list(req):
    req.content_type = 'application/json; charset=UTF8'

    try:
        return json.dumps({
            'Result': 'OK',
            'Records': config.list_speeddial_numbers()
        })
    except Exception, e:
        return json.dumps({'Result': 'ERROR', 'Message': str(e)})
def convert(number):
    with Logger(__name__ + '.convert') as log:

        # read speeddial numbers from config
        speeddial_numbers = config.list_speeddial_numbers()

        for entry in speeddial_numbers:
            if (entry['shortcut'] == number):
                # remove non-digit characters
                expanded_number = re.sub('[^0-9]+', '', entry['phonenumber'])                
                log.debug('Speeddial number found: ' + number + ' => ' + expanded_number)
                return expanded_number
            
        # no speeddial number found
        return number
Exemple #6
0
def convert(number):
    with Logger(__name__ + '.convert') as log:

        # read speeddial numbers from config
        speeddial_numbers = config.list_speeddial_numbers()

        for entry in speeddial_numbers:
            if (entry['shortcut'] == number):
                # remove non-digit characters
                expanded_number = re.sub('[^0-9]+', '', entry['phonenumber'])
                log.debug('Speeddial number found: ' + number + ' => ' +
                          expanded_number)
                return expanded_number

        # no speeddial number found
        return number