本文整理汇总了Python中pillow_retry.models.PillowError.bulk_reset_attempts方法的典型用法代码示例。如果您正苦于以下问题:Python PillowError.bulk_reset_attempts方法的具体用法?Python PillowError.bulk_reset_attempts怎么用?Python PillowError.bulk_reset_attempts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pillow_retry.models.PillowError
的用法示例。
在下文中一共展示了PillowError.bulk_reset_attempts方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bulk_reset
# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import bulk_reset_attempts [as 别名]
def test_bulk_reset(self):
for i in range(0, 5):
error = create_error(_change(id=i), attempts=const.PILLOW_RETRY_QUEUE_MAX_PROCESSING_ATTEMPTS)
error.save()
errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
self.assertEqual(len(errors), 0)
PillowError.bulk_reset_attempts(datetime.utcnow())
errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
self.assertEqual(len(errors), 5)
示例2: test_bulk_reset_cutoff
# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import bulk_reset_attempts [as 别名]
def test_bulk_reset_cutoff(self):
for i in range(0, 3):
error = create_error(_change(id=i), attempts=1)
if i >= 1:
error.total_attempts = const.PILLOW_RETRY_MULTI_ATTEMPTS_CUTOFF + 1
error.save()
errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
self.assertEqual(len(errors), 0)
PillowError.bulk_reset_attempts(datetime.utcnow())
errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
self.assertEqual(len(errors), 2)
示例3: test_bulk_reset_cutoff
# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import bulk_reset_attempts [as 别名]
def test_bulk_reset_cutoff(self):
for i in range(0, 3):
error = create_error({'id': i}, attempts=1)
if i >= 1:
error.total_attempts = PillowError.multi_attempts_cutoff() + 1
error.save()
errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
self.assertEqual(len(errors), 0)
PillowError.bulk_reset_attempts(datetime.utcnow())
errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
self.assertEqual(len(errors), 2)
示例4: handle
# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import bulk_reset_attempts [as 别名]
def handle(self, *args, **options):
root_dir = settings.FILEPATH
git_snapshot = gitinfo.get_project_snapshot(root_dir, submodules=True)
git_snapshot['diff_url'] = options.get('url', None)
deploy = HqDeploy(
date=datetime.utcnow(),
user=options['user'],
environment=options['environment'],
code_snapshot=git_snapshot,
)
deploy.save()
# reset PillowTop errors in the hope that a fix has been deployed
rows_updated = PillowError.bulk_reset_attempts(datetime.utcnow())
if rows_updated:
print "\n---------------- Pillow Errors Reset ----------------\n" \
"{} pillow errors queued for retry\n".format(rows_updated)
if options['mail_admins']:
snapshot_table = render_to_string('hqadmin/partials/project_snapshot.html', dictionary={'snapshot': git_snapshot})
message = "Deployed by %s, cheers!" % options['user']
snapshot_body = "<html><head><title>Deploy Snapshot</title></head><body><h2>%s</h2>%s</body></html>" % (message, snapshot_table)
call_command('mail_admins', snapshot_body, **{'subject': 'Deploy successful', 'html': True})
示例5: handle
# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import bulk_reset_attempts [as 别名]
def handle(self, *args, **options):
root_dir = settings.FILEPATH
git_snapshot = gitinfo.get_project_snapshot(root_dir, submodules=True)
compare_url = git_snapshot['diff_url'] = options.get('url', None)
deploy = HqDeploy(
date=datetime.utcnow(),
user=options['user'],
environment=options['environment'],
code_snapshot=git_snapshot,
)
deploy.save()
# reset PillowTop errors in the hope that a fix has been deployed
rows_updated = PillowError.bulk_reset_attempts(datetime.utcnow())
if rows_updated:
print "\n---------------- Pillow Errors Reset ----------------\n" \
"{} pillow errors queued for retry\n".format(rows_updated)
deploy_notification_text = (
"CommCareHQ has been successfully deployed to *{}* by *{}*. "
"Find the diff {{diff_link}}".format(
options['environment'],
options['user'],
)
)
if hasattr(settings, 'MIA_THE_DEPLOY_BOT_API'):
link = diff_link(STYLE_SLACK, compare_url)
requests.post(settings.MIA_THE_DEPLOY_BOT_API, data=json.dumps({
"username": "Igor the Iguana",
"text": deploy_notification_text.format(diff_link=link),
}))
if settings.DATADOG_API_KEY:
tags = ['environment:{}'.format(options['environment'])]
link = diff_link(STYLE_MARKDOWN, compare_url)
datadog_api.Event.create(
title="Deploy Success",
text=deploy_notification_text.format(diff_link=link),
tags=tags,
alert_type="success"
)
print "\n=============================================================\n" \
"Congratulations! Deploy Complete.\n\n" \
"Don't forget to keep an eye on the deploy dashboard to " \
"make sure everything is running smoothly.\n\n" \
"https://p.datadoghq.com/sb/5c4af2ac8-1f739e93ef" \
"\n=============================================================\n"
if options['mail_admins']:
message_body = get_deploy_email_message_body(
environment=options['environment'], user=options['user'],
compare_url=compare_url)
call_command('mail_admins', message_body, **{'subject': 'Deploy successful', 'html': True})
示例6: handle
# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import bulk_reset_attempts [as 别名]
def handle(self, *args, **options):
root_dir = settings.FILEPATH
git_snapshot = gitinfo.get_project_snapshot(root_dir, submodules=True)
git_snapshot['diff_url'] = options.get('url', None)
deploy = HqDeploy(
date=datetime.utcnow(),
user=options['user'],
environment=options['environment'],
code_snapshot=git_snapshot,
)
deploy.save()
# reset PillowTop errors in the hope that a fix has been deployed
rows_updated = PillowError.bulk_reset_attempts(datetime.utcnow())
if rows_updated:
print "\n---------------- Pillow Errors Reset ----------------\n" \
"{} pillow errors queued for retry\n".format(rows_updated)
deploy_notification_text = (
"CommCareHQ has been successfully deployed to *{}* by *{}*. "
"Find the diff {{diff_link}}".format(
options['environment'],
options['user'],
)
)
if hasattr(settings, 'MIA_THE_DEPLOY_BOT_API'):
link = diff_link(STYLE_SLACK, git_snapshot['diff_url'])
requests.post(settings.MIA_THE_DEPLOY_BOT_API, data=json.dumps({
"channel": "#dev",
"username": "Mia the Deploy Bot",
"text": deploy_notification_text.format(diff_link=link),
"icon_emoji": ":see_no_evil:"
}))
if settings.DATADOG_API_KEY:
tags = ['environment:{}'.format(options['environment'])]
link = diff_link(STYLE_MARKDOWN, git_snapshot['diff_url'])
datadog_api.Event.create(
title="Deploy Success",
text=deploy_notification_text.format(diff_link=link),
tags=tags
)
if options['mail_admins']:
snapshot_table = render_to_string('hqadmin/partials/project_snapshot.html', dictionary={'snapshot': git_snapshot})
message = "Deployed by %s, cheers!" % options['user']
snapshot_body = "<html><head><title>Deploy Snapshot</title></head><body><h2>%s</h2>%s</body></html>" % (message, snapshot_table)
call_command('mail_admins', snapshot_body, **{'subject': 'Deploy successful', 'html': True})
示例7: handle
# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import bulk_reset_attempts [as 别名]
def handle(self, **options):
compare_url = options.get('url', None)
minutes = options.get('minutes', None)
deploy = HqDeploy(
date=datetime.utcnow(),
user=options['user'],
environment=options['environment'],
diff_url=compare_url
)
deploy.save()
# reset PillowTop errors in the hope that a fix has been deployed
rows_updated = PillowError.bulk_reset_attempts(datetime.utcnow())
if rows_updated:
print("\n---------------- Pillow Errors Reset ----------------\n" \
"{} pillow errors queued for retry\n".format(rows_updated))
deploy_notification_text = (
"CommCareHQ has been successfully deployed to *{}* by *{}* in *{}* minutes. ".format(
options['environment'],
options['user'],
minutes or '?',
)
)
if options['environment'] == 'production':
deploy_notification_text += "Monitor the {dashboard_link}. "
if settings.MOBILE_INTEGRATION_TEST_TOKEN:
deploy_notification_text += "Check the integration {integration_tests_link}. "
requests.get(
'https://jenkins.dimagi.com/job/integration-tests/build',
params={'token': settings.MOBILE_INTEGRATION_TEST_TOKEN},
)
requests.get(
'https://jenkins.dimagi.com/job/integration-tests-pipeline/build',
params={'token': settings.MOBILE_INTEGRATION_TEST_TOKEN},
)
deploy_notification_text += "Find the diff {diff_link}"
if hasattr(settings, 'MIA_THE_DEPLOY_BOT_API'):
link = diff_link(STYLE_SLACK, compare_url)
if options['environment'] == 'staging':
channel = '#staging'
elif options['environment'] == 'icds':
channel = '#nic-server-standup'
else:
channel = '#hq-ops'
requests.post(settings.MIA_THE_DEPLOY_BOT_API, data=json.dumps({
"username": "Igor the Iguana",
"channel": channel,
"text": deploy_notification_text.format(
dashboard_link=dashboard_link(STYLE_SLACK, DASHBOARD_URL),
diff_link=link,
integration_tests_link=integration_tests_link(STYLE_SLACK, INTEGRATION_TEST_URL)
),
}))
if settings.DATADOG_API_KEY:
tags = ['environment:{}'.format(options['environment'])]
link = diff_link(STYLE_MARKDOWN, compare_url)
datadog_api.Event.create(
title="Deploy Success",
text=deploy_notification_text.format(
dashboard_link=dashboard_link(STYLE_MARKDOWN, DASHBOARD_URL),
diff_link=link,
integration_tests_link=integration_tests_link(STYLE_MARKDOWN, INTEGRATION_TEST_URL)
),
tags=tags,
alert_type="success"
)
print("\n=============================================================\n" \
"Congratulations! Deploy Complete.\n\n" \
"Don't forget to keep an eye on the deploy dashboard to " \
"make sure everything is running smoothly.\n\n" \
"https://p.datadoghq.com/sb/5c4af2ac8-1f739e93ef" \
"\n=============================================================\n")
if options['mail_admins']:
message_body = get_deploy_email_message_body(user=options['user'], compare_url=compare_url)
call_command('mail_admins', message_body, **{'subject': 'Deploy successful', 'html': True})
if settings.DAILY_DEPLOY_EMAIL:
recipient = settings.DAILY_DEPLOY_EMAIL
subject = 'Deploy Successful - {}'.format(options['environment'])
send_HTML_email(subject=subject,
recipient=recipient,
html_content=message_body)
if settings.SENTRY_CONFIGURED and settings.SENTRY_API_KEY:
create_update_sentry_release()
notify_sentry_deploy(minutes)