當前位置: 首頁>>代碼示例>>Python>>正文


Python Tasks.remove方法代碼示例

本文整理匯總了Python中tasks.models.Tasks.remove方法的典型用法代碼示例。如果您正苦於以下問題:Python Tasks.remove方法的具體用法?Python Tasks.remove怎麽用?Python Tasks.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tasks.models.Tasks的用法示例。


在下文中一共展示了Tasks.remove方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: token_service

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import remove [as 別名]
def token_service(data):
    """Find project by token and create task

    :param data: Data received from service
    :type data: dict
    :returns: bson.ObjectId or None -- pk of created task
    """
    try:
        project = Project.objects.get(token=data['service']['token'])

        assert data['project'] == project.name

        return Tasks.save(data)
    except Exception as e:
        # remove task on error
        Tasks.remove(data['_id'])
        logger.exception('Token service fail: {}'.format(e))
開發者ID:coviolations,項目名稱:coviolations_web,代碼行數:19,代碼來源:token.py

示例2: travis_ci_service

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import remove [as 別名]
def travis_ci_service(data):
    """Create tasks from data received from travis-c

    :param data: Data received from service
    :type data: dict
    :returns: bson.ObjectId or None -- pk of created task
    """
    try:
        assert Tasks.find({
            'service.name': 'travis_ci',
            'service.job_id': data['service']['job_id'],
        }).count() <= 1

        job = requests.get(
            'https://api.travis-ci.org/jobs/{}'.format(
                data['service']['job_id'],
            ),
        ).json()

        repo = requests.get(
            'https://api.travis-ci.org/repos/{}'.format(
                job['repository_id'],
            ),
        ).json()

        # TODO: add pull request support
        assert data['project'] == repo['slug']

        if data['service'].get('pull_request_id'):
            pull_request = data['service']['pull_request_id']
            if pull_request != 'false':
                data['pull_request_id'] = int(
                    data['service']['pull_request_id'],
                )

        return Tasks.save(data)
    except Exception as e:
        # remove task on error
        Tasks.remove(data['_id'])
        logger.exception('Travis-ci service fail: {}'.format(e))
開發者ID:coviolations,項目名稱:coviolations_web,代碼行數:42,代碼來源:travis_ci.py

示例3: coviolations_service

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import remove [as 別名]
def coviolations_service(data):
    """Find project by token and create task

    :param data: Data received from service
    :type data: dict
    :returns: bson.ObjectId or None -- pk of created task
    """
    try:
        project = Project.objects.get(token=data['service']['token'])
        node_task = NodeTask.objects.get(
            id=data['service']['task_id'],
            project=project,
        )
        data['commit']['branch'] = node_task.branch

        assert data['project'] == project.name

        return Tasks.save(data)
    except Exception as e:
        # remove task on error
        Tasks.remove(data['_id'])
        logger.exception('Token service fail: {}'.format(e))
開發者ID:michaeljoseph,項目名稱:coviolations_web,代碼行數:24,代碼來源:coviolations.py


注:本文中的tasks.models.Tasks.remove方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。