示例#1
0
def notify_mage_task(channel_uuid, action):
    mage = MageClient(settings.MAGE_API_URL, settings.MAGE_AUTH_TOKEN)
    if action == 'add':
        mage.add_twitter_stream(channel_uuid)
    elif action == 'remove':
        mage.remove_twitter_stream(channel_uuid)
    else:
        raise ValueError('Invalid action: %s' % action)
示例#2
0
def notify_mage_task(channel_uuid, action):
    """
    Notifies Mage of a change to a Twitter channel
    """
    mage = MageClient(settings.MAGE_API_URL, settings.MAGE_AUTH_TOKEN)

    if action == MageStreamAction.activate:
        mage.activate_twitter_stream(channel_uuid)
    elif action == MageStreamAction.refresh:
        mage.refresh_twitter_stream(channel_uuid)
    elif action == MageStreamAction.deactivate:
        mage.deactivate_twitter_stream(channel_uuid)
    else:  # pragma: no cover
        raise ValueError('Invalid action: %s' % action)
示例#3
0
def notify_mage_task(channel_uuid, action):
    mage = MageClient(settings.MAGE_API_URL, settings.MAGE_AUTH_TOKEN)
    if action == 'add':
        mage.add_twitter_stream(channel_uuid)
    elif action == 'remove':
        mage.remove_twitter_stream(channel_uuid)
    else:
        raise ValueError('Invalid action: %s' % action)
示例#4
0
文件: tasks.py 项目: Ebaneck/rapidpro
def notify_mage_task(channel_uuid, action):
    """
    Notifies Mage of a change to a Twitter channel. Having this in a djcelery_transactions task ensures that the channel
    db object is updated before Mage tries to fetch it
    """
    mage = MageClient(settings.MAGE_API_URL, settings.MAGE_AUTH_TOKEN)

    if action == MageStreamAction.activate:
        mage.activate_twitter_stream(channel_uuid)
    elif action == MageStreamAction.refresh:
        mage.refresh_twitter_stream(channel_uuid)
    elif action == MageStreamAction.deactivate:
        mage.deactivate_twitter_stream(channel_uuid)
    else:  # pragma: no cover
        raise ValueError('Invalid action: %s' % action)