当前位置: 首页>>代码示例>>Python>>正文


Python Context.roaming方法代码示例

本文整理汇总了Python中context.Context.roaming方法的典型用法代码示例。如果您正苦于以下问题:Python Context.roaming方法的具体用法?Python Context.roaming怎么用?Python Context.roaming使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在context.Context的用法示例。


在下文中一共展示了Context.roaming方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import roaming [as 别名]

#.........这里部分代码省略.........
                    % emergency_contact)
            processed = 1
            # check if emergency_contacts is a list of numbers
            dial_str = ''
            if ',' in emergency_contact:
                emg_numbers = emergency_contact.split(',')
                last = emg_numbers[-1]
                for emg in emg_numbers:
                    if emg == last:
                        dial_str += 'sofia/internal/sip:'+emg+'@172.16.0.1:5050'
                    else:
                        dial_str += 'sofia/internal/sip:'+emg+'@172.16.0.1:5050,'
            else:
                dial_str = 'sofia/internal/sip:'+emergency_contact+'@172.16.0.1:5050'
            
            self.session.setVariable('context','EMERGENCY')
            self.session.execute('bridge', "{absolute_codec_string='GSM'}"+dial_str)
            
        # check if destination number is an incoming call
        # lookup dest number in DID table.
        if processed == 0:
            try:
                if (self._n.is_number_did(self.destination_number)):
                    log.info('Called number is a DID')
                    log.debug('Execute context INBOUND call')
                    processed = 1
                    # send call to IVR execute context
                    self.session.setVariable('inbound_loop', '0')
                    self.context.inbound()
            except NumberingException as e:
                log.error(e)

            # check if calling number or destination number is a roaming subscriber
            log.info('Check if calling/called number is roaming')
            try:
                if (self._n.is_number_roaming(self.calling_number)):
                    processed = 1
                    log.info('Calling number %s is roaming' % self.calling_number)
                    self.context.roaming('caller')
            except NumberingException as e:
                log.error(e)
                # TODO: play message of calling number is not authorized to call
                self.session.hangup()

            try:
                if (self._n.is_number_roaming(self.destination_number)):
                    processed = 1
                    log.info(
                        'Destination number %s is roaming'
                        % self.destination_number)
                    self.context.roaming('called')
            except NumberingException as e:
                log.error(e)
                # TODO: play message of destination number
                # unauthorized to receive call
                self.session.hangup()

            # check if destination number is an international call.
            # prefix with + or 00
            if (
                self.destination_number[0] == '+' or (
                    re.search(r'^00', self.destination_number) is not None)
            ) and processed == 0:
                log.debug('Called number is an international call or national')
                processed = 1
                log.debug(
开发者ID:ciaby,项目名称:rccn,代码行数:70,代码来源:dialplan.py

示例2: __init__

# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import roaming [as 别名]

#.........这里部分代码省略.........

    def check_support(self):
        if not 'support_contact' in globals() or support_contact == '':
            log.info('Support Call but no support number :(')
            self.play_announcement("RESOURCE_UNAVAIL")
            return False
        log.info('!!Support Call (%s)', self.destination_number)
        self.session.setVariable('context', "SUPPORT")
        self.session.setVariable('destination_number', support_contact)
        self.destination_number = support_contact
        self.context.destination_number = support_contact
        return self.context.bridge(support_contact)

    def check_did(self):
        if self.calling_host == mncc_ip_address:
            return
        try:
            if not self._n.is_number_did(self.destination_number):
                return False
        except NumberingException as _ex:
            log.error(_ex)
            return -1
        log.info('Called number is a DID')
        log.info("Caller from: %s", self.calling_host)
        if self.calling_host == mncc_ip_address:
            log.info("Call to DID from GSM side.")
            self.play_announcement("OUTGOING_CALL_BARRED")
            self.session.hangup('OUTGOING_CALL_BARRED')
            #self.session.hangup('CALL_REJECTED')
            return -1
        log.debug('Execute context INBOUND call')
        return self.context.inbound()

    def check_roaming(self):
        log.debug('Check call from(%s/%s) for roaming', self.calling_number, self.calling_host)
        if self.check_roaming_caller():
            return True
        return self.check_roaming_destination()

    def check_roaming_caller(self):
        if (self.caller_is_local() and
                self.calling_number[:6] != config['internal_prefix']): # so has to be "roaming"
            try:
                _tagged_roaming = self._n.is_number_roaming(self.calling_number)
            except NumberingException as _ex:
                log.error(_ex)
                self.play_announcement("INCOMING_CALL_BARRED")
                self.session.hangup('SERVICE_UNAVAILABLE')
                return True
            log.info('Calling number %s is roaming (%s)', self.calling_number, _tagged_roaming)
            self.context.roaming_caller()
            return True
        if (not self.caller_is_local() and
                self.calling_number[:6] == config['internal_prefix']):
            log.info('Our roaming user (%s) is calling (%s) here.', self.calling_number, self.destination_number)
            self.context.roaming_caller()

    def check_roaming_destination(self):
        try:
            _tagged_roaming = self._n.is_number_roaming(self.destination_number)
            if (self.calling_host != mncc_ip_address and
                    self.destination_number[:6] != config['internal_prefix'] and
                    self._n.is_number_known(self.destination_number)):
                log.info('Incoming call to Foreign destination: %s', self.destination_number)
                self.context.roaming()
                return True
开发者ID:Rhizomatica,项目名称:rccn,代码行数:70,代码来源:dialplan.py


注:本文中的context.Context.roaming方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。