コード例 #1
0
ファイル: tasks.py プロジェクト: AxisOfEval/rapidpro
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
ファイル: tasks.py プロジェクト: xuanhan863/rapidpro
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)