本文整理汇总了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))
示例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))
示例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))