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


Python agid.register函数代码示例

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


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


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