diff options
author | Almog Laktivi <al942u@att.com> | 2017-11-21 10:44:49 +0200 |
---|---|---|
committer | Almog Laktivi <al942u@att.com> | 2017-11-21 10:45:06 +0200 |
commit | 97fc837a29af8757a036eed513b95833f1cdab24 (patch) | |
tree | 37f1387a3fa169c0967a0885c80d3820c0614560 /django | |
parent | 56641b346180779cdb17e351f453513db4d702c9 (diff) |
Fix flake8 remaining problems
shorter lines in files commited
Change-Id: If2a232b0f83f135b60fd74833113e6ac7c0533e2
Issue-ID: VVP-25
Signed-off-by: Almog Laktivi <al942u@att.com>
Diffstat (limited to 'django')
-rw-r--r-- | django/engagementmanager/apps.py | 2 | ||||
-rw-r--r-- | django/engagementmanager/bus/handlers/image_pushed_handler.py | 33 | ||||
-rw-r--r-- | django/engagementmanager/slack_client/api.py | 10 | ||||
-rw-r--r-- | django/engagementmanager/tests/test_rados_gateway.py | 11 | ||||
-rw-r--r-- | django/validationmanager/em_integration/vm_api.py | 24 | ||||
-rw-r--r-- | django/validationmanager/tasks.py | 1 |
6 files changed, 50 insertions, 31 deletions
diff --git a/django/engagementmanager/apps.py b/django/engagementmanager/apps.py index 950fe20..e33f6ed 100644 --- a/django/engagementmanager/apps.py +++ b/django/engagementmanager/apps.py @@ -115,4 +115,4 @@ class EngagementmanagerConfig(AppConfig): DailyNotifyInactiveEngagementsHandler(), DailyScheduledMessage) bus_service.register( CheckNewsAndAnnouncementsHandler(), HourlyScheduledMessage) - bus_service.register(ImagePushedHandler(), HourlyScheduledMessage)
\ No newline at end of file + bus_service.register(ImagePushedHandler(), HourlyScheduledMessage) 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) diff --git a/django/engagementmanager/slack_client/api.py b/django/engagementmanager/slack_client/api.py index df149ed..4e2b8da 100644 --- a/django/engagementmanager/slack_client/api.py +++ b/django/engagementmanager/slack_client/api.py @@ -233,8 +233,10 @@ class SlackClient(object): reviewer, peer_reviewer, bucket_name): - str_committed_files = "The following bucket was updated with new image files: %s" % bucket_name - message = 'The rgwa bucket for the engagement _{}: {}_ in which you are assigned as a _{}_ was updated. ' + \ + str_committed_files = "The following bucket was updated with new" \ + " image files: %s" % bucket_name + message = 'The rgwa bucket for the engagement _{}: {}_ in which you' \ + ' are assigned as a _{}_ was updated. ' + \ str_committed_files self.send_message_to_user( reviewer, @@ -253,7 +255,9 @@ class SlackClient(object): # checklist def send_notification_to_reviewer_when_automation_completes( self, engagement_manual_id, vf_name, reviewer, checklist_name): - message = 'The automation phase completed for the checklist _{}_ under the engagement _{}: {}_. You can now start your review of it.' + message = 'The automation phase completed for the checklist _{}_' \ + ' under the engagement _{}: {}_. You can now start your' \ + ' review of it.' self.send_message_to_user( reviewer, message.format( diff --git a/django/engagementmanager/tests/test_rados_gateway.py b/django/engagementmanager/tests/test_rados_gateway.py index 4a48f58..0b8f504 100644 --- a/django/engagementmanager/tests/test_rados_gateway.py +++ b/django/engagementmanager/tests/test_rados_gateway.py @@ -39,14 +39,17 @@ import json import time -from engagementmanager.bus.messages.hourly_scheduled_message import HourlyScheduledMessage -from engagementmanager.tests.test_base_transaction_entity import TestBaseTransactionEntity +from engagementmanager.bus.messages.hourly_scheduled_message \ + import HourlyScheduledMessage +from engagementmanager.tests.test_base_transaction_entity \ + import TestBaseTransactionEntity from engagementmanager.apps import bus_service from django.conf import settings import mock from rest_framework.status import HTTP_202_ACCEPTED from engagementmanager.models import Vendor, Checklist -from engagementmanager.utils.constants import Constants, EngagementStage, CheckListState +from engagementmanager.utils.constants import Constants, EngagementStage,\ + CheckListState from wheel.signatures import assertTrue @@ -272,7 +275,7 @@ class RadosGatewayTestCase(TestBaseTransactionEntity): self.vf.name = "static-vf-name" self.vf.save() self.template = self.creator.createDefaultCheckListTemplate() - checklist = self.creator.createCheckList( + self.creator.createCheckList( "cl-name", "review", 1, diff --git a/django/validationmanager/em_integration/vm_api.py b/django/validationmanager/em_integration/vm_api.py index 6fb422b..d93dd5b 100644 --- a/django/validationmanager/em_integration/vm_api.py +++ b/django/validationmanager/em_integration/vm_api.py @@ -50,7 +50,8 @@ from engagementmanager.models import Engagement, IceUserProfile, \ ChecklistTemplate, VF from engagementmanager.serializers import VFModelSerializerForSignal from engagementmanager.utils.constants import Roles, EngagementStage, \ - CheckListLineType, JenkinsBuildParametersNames, RGWApermission, CheckListCategory + CheckListLineType, JenkinsBuildParametersNames, RGWApermission,\ + CheckListCategory from engagementmanager.utils.cryptography import CryptographyText from engagementmanager.utils.validator import logEncoding from mocks.gitlab_mock.rest.gitlab_files_respons_rest import \ @@ -105,16 +106,17 @@ def cl_from_pending_to_automation_callback(vf, checklist): logger.debug( "Engagement Manager has signaled that a checklist state was " + "changed from pending to automation") - if checklist.template and checklist.template.category == CheckListCategory.glance.name: - logger.debug("Triggering image scan") - request_scan(vf, checklist) - elif checklist.template and checklist.template.category == CheckListCategory.heat.name: - logger.debug("Triggering heat template validation") - get_jenkins_client().build_job( - vf.jenkins_job_name(), { - 'checklist_uuid': checklist.uuid, - 'git_repo_url': vf.git_repo_url, - }) + if checklist.template: + if checklist.template.category == CheckListCategory.glance.name: + logger.debug("Triggering image scan") + request_scan(vf, checklist) + elif checklist.template.category == CheckListCategory.heat.name: + logger.debug("Triggering heat template validation") + get_jenkins_client().build_job( + vf.jenkins_job_name(), { + 'checklist_uuid': checklist.uuid, + 'git_repo_url': vf.git_repo_url, + }) def provision_new_vf_callback(vf): diff --git a/django/validationmanager/tasks.py b/django/validationmanager/tasks.py index 5d7b0d2..87f414f 100644 --- a/django/validationmanager/tasks.py +++ b/django/validationmanager/tasks.py @@ -1,6 +1,5 @@ from celery import Celery from django.conf import settings -from engagementmanager.models import CheckListState celery_app = Celery( broker='redis://redis', |