コード例 #1
0
    def caller_id_name(self, value):
        if value is None:
            if self.endpoint_sip_uuid or self.endpoint_sccp_id or self.endpoint_custom_id:
                raise InputError("Cannot set caller id to None")
            return

        if self.endpoint_sip_uuid:
            self._set_sip_caller_id_name(value)
        elif self.endpoint_sccp_id:
            self._set_sccp_caller_id_name(value)
        elif self.endpoint_custom_id:
            raise InputError(
                "Cannot set caller id on endpoint of type 'custom'")
        else:
            raise InputError("Cannot set caller id if no endpoint associated")
コード例 #2
0
ファイル: rightcall.py プロジェクト: wazo-platform/xivo-dao
 def mode(self, value):
     if value == 'allow':
         self.authorization = 1
     elif value == 'deny':
         self.authorization = 0
     else:
         raise InputError(
             "cannot set mode to {}. Only 'allow' or 'deny' are authorized".
             format(value))
コード例 #3
0
ファイル: sccpline.py プロジェクト: wazo-platform/xivo-dao
 def set_options(self, values):
     for name, value in values:
         if name == "cid_name":
             self.cid_name = value
         elif name == "cid_num":
             self.cid_num = value
         elif name == "allow":
             self.allow = value
         elif name == "disallow":
             self.disallow = value
         else:
             raise InputError("Unknown SCCP options: {}".format(name))
コード例 #4
0
 def _validate_regexp(self, regexp, value):
     if regexp.match(value) is None:
         raise InputError("exten: ['String does not match expected pattern.']")
コード例 #5
0
ファイル: errors.py プロジェクト: wazo-platform/xivo-dao
def invalid_choice(field, choices, **metadata):
    template = "'{field}' must be one of ({choices})"
    message = template.format(field=field, choices=_format_list(choices))
    error = format_error('Input Error', message, metadata)
    return InputError(error)
コード例 #6
0
ファイル: errors.py プロジェクト: wazo-platform/xivo-dao
def unknown(*params):
    template = "unknown parameters: {params}"
    message = template.format(params=_format_list(params))
    error = format_error('Input Error', message)
    return InputError(error)
コード例 #7
0
ファイル: errors.py プロジェクト: wazo-platform/xivo-dao
def missing(*params):
    template = "missing parameters: {params}"
    message = template.format(params=_format_list(params))
    error = format_error('Input Error', message)
    return InputError(error)