Permalink
Browse files

fixed test_process_batch() and cleaned up some log debugs

  • Loading branch information...
1 parent fcfa05d commit 56db8f7291f67aea24f07bdbacb75928bd30c3f9 @swarbhanu swarbhanu committed Dec 6, 2012
@@ -99,7 +99,7 @@ def process_event(self, msg, headers):
user_ids = []
if self.reverse_user_info:
- log.debug("came here to check the interested users in %s" % msg.type_)
+ log.debug("Notification worker checking for users interested in %s" % msg.type_)
user_ids = check_user_notification_interest(event = msg, reverse_user_info = self.reverse_user_info)
log.debug("Notification worker deduced the following users were interested in the event: %s, event_type: %s, origin: %s" % (user_ids, msg.type_, msg.origin ))
@@ -657,6 +657,7 @@ def process_batch(self, start_time = 0, end_time = 0):
@param start_time int
@param end_time int
"""
+ self.smtp_client = setting_up_smtp_client()
if end_time <= start_time:
return
@@ -704,9 +705,12 @@ def process_batch(self, start_time = 0, end_time = 0):
# send a notification email to each user using a _send_email() method
if events_for_message:
- self.format_and_send_email(events_for_message, user_id)
+ self.format_and_send_email(events_for_message, user_id, self.smtp_client)
- def format_and_send_email(self, events_for_message, user_id):
+ self.smtp_client.quit()
+
+
+ def format_and_send_email(self, events_for_message = None, user_id = None, smtp_client = None):
"""
Format the message for a particular user containing information about the events he is to be notified about
@@ -746,14 +750,11 @@ def format_and_send_email(self, events_for_message, user_id):
msg_subject = "(SysName: " + get_sys_name() + ") ION event "
- smtp_client = setting_up_smtp_client()
-
self.send_batch_email( msg_body = msg_body,
msg_subject = msg_subject,
msg_recipient=self.user_info[user_id]['user_contact'].email,
smtp_client=smtp_client )
- smtp_client.quit()
def send_batch_email(self, msg_body, msg_subject, msg_recipient, smtp_client):
"""
@@ -199,7 +199,7 @@ def check_user_notification_interest(event, reverse_user_info):
user_list_1 += reverse_user_info['event_origin']['']
users = user_list_1
- log.debug("for event origin %s got interested users here %s" % (event.origin, users))
+ log.debug("For event origin = %s, UNS got interested users here %s" % (event.origin, users))
if reverse_user_info['event_origin_type'].has_key(event.origin_type):
if event.origin_type: # for an incoming event with origin type specified
@@ -208,15 +208,15 @@ def check_user_notification_interest(event, reverse_user_info):
user_list_2 += reverse_user_info['event_origin_type']['']
users = set.intersection(users, user_list_2)
- log.debug("for event_origin_type: %s got interested users here %s" % (event.origin_type, users))
+ log.debug("For event_origin_type = %s too, UNS got interested users here %s" % (event.origin_type, users))
if reverse_user_info['event_type'].has_key(event.type_):
user_list_3 = reverse_user_info['event_type'][event.type_]
if reverse_user_info['event_type'].has_key(''): # for users who subscribe to any event types
user_list_3 += reverse_user_info['event_type']['']
users = set.intersection(users, user_list_3)
- log.debug("for event_type: %s got interested users here %s" % (event.type_, users))
+ log.debug("For event_type = %s too, UNS got interested users here %s" % (event.type_, users))
if reverse_user_info['event_subtype'].has_key(event.sub_type):
@@ -226,7 +226,7 @@ def check_user_notification_interest(event, reverse_user_info):
user_list_4 += reverse_user_info['event_subtype']['']
users = set.intersection(users, user_list_4)
- log.debug("for event_subtype: %s got interested users here %s" % (event.sub_type, users))
+ log.debug("For event_subtype = %s too, UNS got interested users here %s" % (event.sub_type, users))
users = list( users)

0 comments on commit 56db8f7

Please sign in to comment.