summaryrefslogtreecommitdiffstats
path: root/django/engagementmanager/bus/handlers/image_pushed_handler.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/engagementmanager/bus/handlers/image_pushed_handler.py')
-rw-r--r--django/engagementmanager/bus/handlers/image_pushed_handler.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/django/engagementmanager/bus/handlers/image_pushed_handler.py b/django/engagementmanager/bus/handlers/image_pushed_handler.py
index edfb50e..a981f78 100644
--- a/django/engagementmanager/bus/handlers/image_pushed_handler.py
+++ b/django/engagementmanager/bus/handlers/image_pushed_handler.py
@@ -2,7 +2,8 @@ import logging
from django.core.exceptions import ObjectDoesNotExist
-from engagementmanager.bus.handlers.service_bus_base_handler import ServiceBusBaseHandler
+from engagementmanager.bus.handlers.service_bus_base_handler \
+ import ServiceBusBaseHandler
from engagementmanager.slack_client.api import SlackClient
from engagementmanager.models import VF, Checklist, IceUserProfile
from engagementmanager.utils.constants import CheckListState
@@ -16,12 +17,15 @@ logger = logging.getLogger('ice.logger')
class ImagePushedHandler(ServiceBusBaseHandler):
def handle_message(self, bus_message):
- logger.debug("New hourly scheduled message arrived, Will check if there are new images and trigger the "
+ logger.debug("New hourly scheduled message arrived,"
+ " Will check if there are new images and trigger the "
"checklist scan in accordance.")
rgwa = RGWAClientFactory.admin()
start_date = datetime.today() - timedelta(hours=1)
- last_hour_uasge = rgwa.get_usage(show_entries=True, start=start_date.strftime('%Y-%m-%d %H:%M:%S'))
+ last_hour_uasge = rgwa.get_usage(show_entries=True,
+ start=start_date
+ .strftime('%Y-%m-%d %H:%M:%S'))
if last_hour_uasge is not None and 'entries' in last_hour_uasge:
for entry in last_hour_uasge['entries']:
@@ -32,14 +36,19 @@ class ImagePushedHandler(ServiceBusBaseHandler):
# for images, for now this is sufficient but FIXME
# could be more robust.
continue
- if any(category['category'] == 'put_obj' for category in bucket['categories']):
- logger.debug("Found image which updated at the last hour -> will run checklist scan"
+ if any(category['category'] == 'put_obj' for category
+ in bucket['categories']):
+ logger.debug("Found image which updated at the last "
+ "hour -> will run checklist scan"
"for validation.")
- bucket_name_combinations = str(bucket['bucket']).split('_')
- engagement_manual_id = bucket_name_combinations[0]
+ bucket_name_combinations = str(bucket['bucket'])\
+ .split('_')
+ eng_manual_id = bucket_name_combinations[0]
vf_name = bucket_name_combinations[1]
- vf = VF.objects.get(name=vf_name, engagement__engagement_manual_id=engagement_manual_id)
+ vf = VF.objects.get(
+ name=vf_name,
+ engagement__engagement_manual_id=eng_manual_id)
self.validate_vf_exists(vf)
self.notify_slack_users(vf, bucket['bucket'])
self.set_checklist_states(vf)
@@ -53,8 +62,8 @@ class ImagePushedHandler(ServiceBusBaseHandler):
def notify_slack_users(self, vf, bucket_name):
slack_client = SlackClient()
slack_client.send_notifications_bucket_image_update(
- vf.engagement.engagement_manual_id, vf.name, vf.engagement.reviewer,
- vf.engagement.peer_reviewer, bucket_name)
+ vf.engagement.engagement_manual_id, vf.name,
+ vf.engagement.reviewer, vf.engagement.peer_reviewer, bucket_name)
def set_checklist_states(self, vf):
checklists = (Checklist.objects
@@ -71,6 +80,8 @@ class ImagePushedHandler(ServiceBusBaseHandler):
data = set_state(decline=True,
checklist_uuid=checklist.uuid,
isMoveToAutomation=True,
- description="This change was triggered by an update to the engagement rgwa bucket.")
+ description="This change was triggered by an "
+ "update to the engagement rgwa bucket"
+ ".")
logger.debug("set_state returned (%r)" % data)