• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python agid.register函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xivo_agid.agid.register函数的典型用法代码示例。如果您正苦于以下问题:Python register函数的具体用法?Python register怎么用?Python register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: alarmclk_set


def alarmclk_set(agi, cursor, args):
    userid = int(args[0])
    raw_alarm_clock = args[1]
    
    try:
        hour, minute = _parse_inputted_alarm_clock(raw_alarm_clock)
    except ValueError, e:
        logger.warning('Invalid alarm clock input for user %s: %s', e, userid)
        agi.set_variable('XIVO_ALARMCLK_OK', '0')
    else:
        alarm_clock = '%s:%s' % (hour, minute)
        _update_alarmclock_webi(userid, alarm_clock)
        agi.set_variable('XIVO_ALARMCLK_OK', '1')


def alarmclk_clear(agi, cursor, args):
    userid = int(args[0])
    
    cur_alarmclock = _get_alarmclock_db(cursor, userid)
    if cur_alarmclock:
        _update_alarmclock_webi(userid, '')
    else:
        logger.info('No alarm clock set for user %s', userid)


agid.register(alarmclk_pre_execute)
agid.register(alarmclk_set)
agid.register(alarmclk_clear)
开发者ID:Eyepea,项目名称:xivo-skaro,代码行数:28,代码来源:alarmclk.py


示例2: phone_get_features


def phone_get_features(agi, cursor, args):
    userid = agi.get_variable('XIVO_USERID')

    feature_list = objects.ExtenFeatures(agi, cursor)

    try:
        user = objects.User(agi, cursor, int(userid))
    except (ValueError, LookupError), e:
        agi.dp_break(str(e))

    for fwd in feature_list.FEATURES['forwards']:
        fwdupper = fwd[1].upper()
        enable = 0
        dest = ""

        if getattr(feature_list, fwd[0], 0) \
                and getattr(user, "enable%s" % fwd[1], 0):
            enable = 1
            dest = getattr(user, "dest%s" % fwd[1], "")

        agi.set_variable("XIVO_ENABLE%s" % fwdupper, enable)
        agi.set_variable("XIVO_DEST%s" % fwdupper, dest)

    for service in feature_list.FEATURES['services']:
        enable = bool(getattr(feature_list, service[0], 0) and getattr(user, service[1], 0))
        agi.set_variable("XIVO_%s" % service[1].upper(), int(enable))

agid.register(phone_get_features)
开发者ID:RaulFRodriguez,项目名称:xivo-agid,代码行数:28,代码来源:phone_get_features.py


示例3: except

        except (ValueError, LookupError), e:
            user = None
            agi.verbose(str(e))
    else:
        user = None

    try:
        handy_number = objects.HandyNumber(agi, cursor, exten=exten_pattern)
    except LookupError, e:
        agi.dp_break(str(e))

    trunk = handy_number.trunk

    agi.set_variable('XIVO_INTERFACE', trunk.interface)
    agi.set_variable('XIVO_TRUNKEXTEN', dstnum)

    if trunk.intfsuffix:
        intfsuffix = trunk.intfsuffix
    else:
        intfsuffix = ""

    agi.set_variable('XIVO_TRUNKSUFFIX', intfsuffix)

    if user and user.outcallerid and user.outcallerid != 'default':
        objects.CallerID.set(agi, user.outcallerid)

        if user.outcallerid == 'anonymous':
            agi.appexec('SetCallerPres', 'prohib')

agid.register(handynumbers)
开发者ID:Eyepea,项目名称:xivo-gallifrey,代码行数:30,代码来源:handynumbers.py


示例4: fwdundoall

    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

from xivo_agid import agid
from xivo_agid import objects

def fwdundoall(agi, cursor, args):
    userid = agi.get_variable('XIVO_USERID')

    try:
        user = objects.User(agi, cursor, int(userid))
    except (ValueError, LookupError), e:
        agi.dp_break(str(e))

    try:
        user.disable_forwards()
    except objects.DBUpdateException, e:
        agi.verbose(str(e))

agid.register(fwdundoall)
开发者ID:Eyepea,项目名称:xivo-gallifrey,代码行数:30,代码来源:fwdundoall.py


示例5: Copyright

__license__ = """
    Copyright (C) 2006-2010  Proformatique <[email protected]>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

from xivo_agid import agid
from xivo_agid import objects

def schedule(agi, cursor, args):
    try:
        sched = objects.Schedule(agi, cursor, int(args[0]))
    except (ValueError, LookupError), e:
        agi.dp_break(str(e))

    agi.set_variable("XIVO_SCHEDULE_TIMERANGE", sched.timerange)
    sched.set_dial_actions()

agid.register(schedule)
开发者ID:Eyepea,项目名称:xivo-gallifrey,代码行数:30,代码来源:schedule.py


示例6: int

                         exc_info=True)
            agi.dp_break(str(e))
    else:
        try:
            vmboxid = int(agi.get_variable('XIVO_VMBOXID'))
            vmbox = objects.VMBox(agi, cursor, vmboxid)
        except (ValueError, LookupError), e:
            logger.error('Error while retrieving vmbox from vmboxid',
                         exc_info=True)
            agi.dp_break(str(e))

    if vmbox and vmbox.skipcheckpass:
        vmmain_options = "s"
    else:
        vmmain_options = ""

    if caller and caller.language:
        mbox_lang = caller.language
    elif vmbox and vmbox.language:
        mbox_lang = vmbox.language
    else:
        mbox_lang = ''

    agi.set_variable('XIVO_VMMAIN_OPTIONS', vmmain_options)
    agi.set_variable('XIVO_MAILBOX', vmbox.mailbox)
    agi.set_variable('XIVO_MAILBOX_CONTEXT', vmbox.context)
    agi.set_variable('XIVO_MAILBOX_LANGUAGE', mbox_lang)


agid.register(vmbox_get_info)
开发者ID:Eyepea,项目名称:xivo-skaro,代码行数:30,代码来源:vmbox_get_info.py


示例7: int

            agi.dp_break(str(e))
    else:
        try:
            user = objects.User(agi, cursor, int(userid))
        except (ValueError, LookupError), e:
            agi.dp_break(str(e))

    try:
        fklist = split_extension(args[0])
    except ValueError, e:
        agi.dp_break(str(e))

    if userid != fklist[0]:
        agi.dp_break("Wrong userid. (userid: %r, excepted: %r)" % (fklist[0], userid))

    feature = ""

    try:
        extenfeatures = objects.ExtenFeatures(agi, cursor)
        feature = extenfeatures.get_name_by_exten(fklist[1])
    except LookupError, e:
        feature = ""
        agi.verbose(str(e))

    agi.set_variable('XIVO_PHONE_CONTEXT', user.context)
    agi.set_variable('XIVO_PHONE_PROGFUNCKEY', ''.join(fklist[1:]))
    agi.set_variable('XIVO_PHONE_PROGFUNCKEY_STATE', 'NOTHING')
    agi.set_variable('XIVO_PHONE_PROGFUNCKEY_FEATURE', feature)

agid.register(phone_progfunckey)
开发者ID:Eyepea,项目名称:xivo-gallifrey,代码行数:30,代码来源:phone_progfunckey.py


示例8: Copyright

# -*- coding: UTF-8 -*-

__license__ = """
    Copyright (C) 2012  Avencall

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

from xivo_agid import agid


def callerid_extend(agi, cursor, args):
    if 'agi_callington' in agi.env:
        agi.set_variable('XIVO_SRCTON', agi.env['agi_callington'])


agid.register(callerid_extend)
开发者ID:Eyepea,项目名称:xivo-skaro,代码行数:28,代码来源:callerid_extend.py


示例9: len

    agi.set_variable('XIVO_REAL_CONTEXT', group.context)
    agi.set_variable('XIVO_GROUPNAME', group.name)
    agi.set_variable('XIVO_GROUPOPTIONS', options)
    agi.set_variable('XIVO_GROUPNEEDANSWER', needanswer)

    if group.preprocess_subroutine:
        preprocess_subroutine = group.preprocess_subroutine
    else:
        preprocess_subroutine = ""

    if group.timeout:
        timeout = group.timeout
    else:
        timeout = ""

    agi.set_variable('XIVO_GROUPPREPROCESS_SUBROUTINE', preprocess_subroutine)
    agi.set_variable('XIVO_GROUPTIMEOUT', timeout)

    group.set_dial_actions()

    if referer == ("group:%s" % group.id) or referer.startswith("voicemenu:"):
        group.rewrite_cid()

    # schedule
    path = agi.get_variable('XIVO_PATH')
    if path is None or len(path) == 0:
        agi.set_variable('XIVO_PATH'   , 'group')
        agi.set_variable('XIVO_PATH_ID', group.id)

agid.register(incoming_group_set_features)
开发者ID:Eyepea,项目名称:xivo-skaro,代码行数:30,代码来源:incoming_group_set_features.py


示例10: set

        agi.verbose("Invalid feature: %r" % feature)
        return

    try:
        featureexten = extenfeatures.get_exten_by_name(feature)
    except LookupError, e:
        agi.verbose(str(e))
        return

    xset = set()
    forwards = dict(extenfeatures.FEATURES['forwards'])

    if feature in forwards:
        try:
            xset.add(fkey_extension(ppfkexten,
                                    (user.id,
                                     featureexten,
                                     getattr(user, "dest%s" % forwards[feature], ""))))
        except ValueError, e:
            agi.verbose(str(e))
    else:
        xset.add(fkey_extension(ppfkexten,
                                (user.id,
                                 featureexten,
                                 dest)))

    for x in xset:
        agi.set_variable("DEVICE_STATE(Custom:%s)" % x, devstate)

agid.register(phone_progfunckey_devstate)
开发者ID:Eyepea,项目名称:xivo-skaro,代码行数:30,代码来源:phone_progfunckey_devstate.py


示例11: except

        try: 
            protocol, name = member.split('/', 1)
            user = objects.User(agi, cursor, name=name, protocol=protocol)
        except (ValueError, LookupError):
            continue

        if user.number:
            pickupmark.append("%s%%%s" % (user.number, user.context))

    agi.set_variable('__PICKUPMARK', '&'.join(pickupmark))

    if queue.preprocess_subroutine:
        preprocess_subroutine = queue.preprocess_subroutine
    else:
        preprocess_subroutine = ""

    if queue.timeout:
        timeout = queue.timeout
    else:
        timeout = ""

    agi.set_variable('XIVO_QUEUEPREPROCESS_SUBROUTINE', preprocess_subroutine)
    agi.set_variable('XIVO_QUEUETIMEOUT', timeout)

    queue.set_dial_actions()

    if referer == ("queue:%s" % queue.id) or referer.startswith("voicemenu:"):
        queue.rewrite_cid()

agid.register(incoming_queue_set_features)
开发者ID:Eyepea,项目名称:xivo-gallifrey,代码行数:30,代码来源:incoming_queue_set_features.py


示例12: callfilter

def callfilter(agi, cursor, args):
    callfiltermember_id = args[0]

    if not callfiltermember_id.isdigit():
        agi.dp_break('This id "%s" is not a valid callfiltermember_id id.' % callfiltermember_id)

    caller_user_id = agi.get_variable(dialplan_variables.USERID)
    callfiltermember = callfilter_dao.get_by_callfiltermember_id(callfiltermember_id)
    if not callfiltermember:
        agi.dp_break('This callfilter does not exist.')

    bslist = callfilter_dao.get(callfiltermember.callfilterid)
    if not bslist:
        agi.dp_break('This callfilter has no member.')

    allow_ids = []
    for bs in bslist:
        callfilter, callfiltermembers = bs
        allow_ids.append(callfiltermembers.typeval)

    if not caller_user_id or caller_user_id not in allow_ids:
        agi.dp_break('This user is not allowed to use this callfilter.')

    new_state = 0 if callfiltermember.active == 1 else 1
    callfilter_dao.update_callfiltermember_state(callfiltermember_id, new_state)
    agi.set_variable('XIVO_BSFILTERENABLED', new_state)


agid.register(callfilter)
开发者ID:RaulFRodriguez,项目名称:xivo-agid,代码行数:29,代码来源:callfilter.py


示例13: agent_logoff

# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

import logging
from xivo_agid import agid
from xivo_agid.handlers import agent

logger = logging.getLogger(__name__)


def agent_logoff(agi, cursor, args):
    try:
        agent_id = int(args[0])

        agent.logoff_agent(agi, agent_id)
    except Exception as e:
        logger.exception("Error while logging off agent")
        agi.dp_break(e)


agid.register(agent_logoff)
开发者ID:RaulFRodriguez,项目名称:xivo-agid,代码行数:30,代码来源:agent_logoff.py


示例14: incoming_did_set_features

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

from xivo_agid import agid
from xivo_agid import objects

def incoming_did_set_features(agi, cursor, args):
    exten_pattern = agi.get_variable('XIVO_EXTENPATTERN')
    context = agi.get_variable('XIVO_CONTEXT')

    did = objects.DID(agi, cursor, exten = exten_pattern, context = context)

    if did.preprocess_subroutine:
        preprocess_subroutine = did.preprocess_subroutine
    else:
        preprocess_subroutine = ""

    agi.set_variable('XIVO_REAL_NUMBER', did.exten)
    agi.set_variable('XIVO_REAL_CONTEXT', did.context)
    agi.set_variable('XIVO_DIDPREPROCESS_SUBROUTINE', preprocess_subroutine)

    # schedule
    agi.set_variable('XIVO_PATH'   , 'incall')
    agi.set_variable('XIVO_PATH_ID', did.id)

    did.set_dial_actions()
    did.rewrite_cid()

agid.register(incoming_did_set_features)
开发者ID:Eyepea,项目名称:xivo-skaro,代码行数:30,代码来源:incoming_did_set_features.py


示例15: agent_get_status

# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

import logging
from xivo_agid import agid
from xivo_agid.handlers import agent

logger = logging.getLogger(__name__)


def agent_get_status(agi, cursor, args):
    try:
        agent_id = int(args[0])

        agent.get_agent_status(agi, agent_id)
    except Exception as e:
        logger.exception("Error while logging off agent")
        agi.dp_break(e)


agid.register(agent_get_status)
开发者ID:RaulFRodriguez,项目名称:xivo-agid,代码行数:30,代码来源:agent_get_status.py


示例16: Copyright

__version__ = "$Revision$ $Date$"
__license__ = """
    Copyright (C) 2009-2010  Proformatique <[email protected]>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

from xivo_agid import agid

def monitoring(agi, cursor, args):
    agi.send_command("Status: OK")

agid.register(monitoring)
开发者ID:Eyepea,项目名称:xivo-gallifrey,代码行数:24,代码来源:monitoring.py


示例17: Copyright

# -*- coding: utf-8 -*-

# Copyright (C) 2006-2014 Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

from xivo_agid import agid
from xivo_agid.handlers.userfeatures import UserFeatures


def incoming_user_set_features(agi, cursor, args):
    userfeatures_handler = UserFeatures(agi, cursor, args)
    userfeatures_handler.execute()

agid.register(incoming_user_set_features)
开发者ID:RaulFRodriguez,项目名称:xivo-agid,代码行数:26,代码来源:incoming_user_set_features.py


示例18: len

    xlen = len(args)

    if xlen > 0 and args[0] != '':
        try:
            context = agi.get_variable('XIVO_BASE_CONTEXT')
            if not context:
                agi.dp_break('Could not get the context of the caller')

            user = objects.User(agi, cursor, exten=args[0], context=context)
        except (ValueError, LookupError), e:
            agi.dp_break(str(e))
    else:
        try:
            user = objects.User(agi, cursor, int(userid))
        except (ValueError, LookupError), e:
            agi.dp_break(str(e))

    if not user.vmbox:
        agi.dp_break("User has no voicemail box (id: %d)" % user.id)

    if user.vmbox.skipcheckpass:
        vmmain_options = "s"
    else:
        vmmain_options = ""

    agi.set_variable('XIVO_VMMAIN_OPTIONS', vmmain_options)
    agi.set_variable('XIVO_MAILBOX', user.vmbox.mailbox)
    agi.set_variable('XIVO_MAILBOX_CONTEXT', user.vmbox.context)

agid.register(user_get_vmbox)
开发者ID:RaulFRodriguez,项目名称:xivo-agid,代码行数:30,代码来源:user_get_vmbox.py


示例19: filter

    if config.has_option("general", "mutt"):
        MUTT_PATH = config.get("general", "mutt")
    if config.has_option("general", "lp"):
        LP_PATH = config.get("general", "lp")

    # 3. create backends
    backends = {}
    for backend_prefix, backend_factory in _BACKENDS_FACTORY:
        for section in filter(lambda s: s.startswith(backend_prefix),
                              config.sections()):
            backend_factory_args = dict(config.items(section))
            logger.debug("Creating backend, name %s, factory %s", section,
                         backend_factory)
            backends[section] = backend_factory(**backend_factory_args)
    logger.debug("Created %s backends", len(backends))

    # 4. creation destinations
    global DESTINATIONS
    DESTINATIONS = {}
    for section in filter(lambda s: s.startswith("dstnum_"), config.sections()):
        cur_destination = section[7:]  # 6 == len("dstnum_")
        cur_backend_ids = map(lambda s: s.strip(), config.get(section, "dest").split(","))
        cur_backends = map(lambda id_: backends[id_], cur_backend_ids)
        logger.debug('Creating destination, dstnum %s, backends %s', cur_destination,
                     cur_backend_ids)
        DESTINATIONS[cur_destination] = cur_backends
    logger.debug("Created %s destinations", len(DESTINATIONS))


agid.register(handle_fax, setup_handle_fax)
开发者ID:RaulFRodriguez,项目名称:xivo-agid,代码行数:30,代码来源:handle_fax.py


示例20: open

    tmpfile = filepath % "tmp"
    realfile = filepath % "outgoing"

    f = open(tmpfile, 'w')
    f.write("Channel: Local/%s\n"
            "MaxRetries: %d\n"
            "RetryTime: %d\n"
            "WaitTime: %d\n"
            "CallerID: %s\n"
            "Context: %s\n"
            "Extension: %s\n"
            "Priority: 1\n" % (srcnum, max_retries, retry_time, wait_time, srcnum, context, dstnum))
    f.close()

    os.utime(tmpfile, (mtime, mtime))
    os.chown(tmpfile, ASTERISK_UID, ASTERISK_GID)
    os.rename(tmpfile, realfile)

def setup(cursor):
    global max_retries
    global retry_time
    global wait_time

    config = ConfigParser.RawConfigParser()
    config.readfp(open(CONFIG_FILE))
    max_retries = config.getint('general', 'max_retries')
    retry_time = config.getint('general', 'retry_time')
    wait_time = config.getint('general', 'wait_time')

agid.register(callback_on_congestion, setup)
开发者ID:Eyepea,项目名称:xivo-gallifrey,代码行数:30,代码来源:callback_on_congestion.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.open_url函数代码示例发布时间:2022-05-26
下一篇:
Python common.open_url函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap