Skip to content

Commit

Permalink
enhance email cc and bcc
Browse files Browse the repository at this point in the history
enhancement & changelog
  • Loading branch information
mythmgn committed Oct 23, 2017
1 parent eca61db commit 6c2807e
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ build.sh
.DS_Store
*.*~
*.log

cup/net/async/msgcenter_dict.py

cup.tar
tmp
24 changes: 24 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
Version 1.6.0 - Under development, not released yet. starting from 2017.9.6 ~
* [Enhancement] cup.mail enhanced for analyzing cc and bcc lists.

Version 1.5.6 - starting from 2017.3.1 ~ 2017.9.5
* [Enhancement] async enhancement for stability
* [New] CycleIDGenerator for generating universally unique_id (ip, port
encoded as part of the id)
* [Enhancement] cup.net.async exits more quickly than before
* [Bug] cup.net.async - Fix CPU-utilization too high bug
* [Bug] cup.net.async - Fix getting-peerinfo bug
* [Bug] cup.res.linux - Kernel version was returned with a tuple
('2', '6', '32') which should be (2, 6, 32)

Version: 1.5.5 - staring from 11.18 ~ 2017.3.1
* [Enhancement] debug method for executor
* [async] CNeedAckMsg & retry mechnism added. CAckMsg added

Version: 1.5.4 - Starting from 2016.9 ~ 2016.11.11
* [Enhancement] generator supports staring point
* [Enhancement] catch exception socket.gaierror when it encounters network
instability
* [Bug] Set up splitter other thant colon in a Configure2Dict with blanks and comments
* [Async] Support automatic msg retry
* [Async] Support ack msg

Version: 1.5.1
* [New] cup.log - add xxx_if
Expand Down
4 changes: 2 additions & 2 deletions cup/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def sendmail(self, recipients, subject='', body='', attachments=None,
if type(cc) == str:
outer['Cc'] = cc
toaddrs.append(cc)
elif type(cc) == list:
elif isinstance(cc, list):
outer['Cc'] = self._COMMA_SPLITTER.join(cc)
toaddrs.extend(cc)
else:
Expand All @@ -263,7 +263,7 @@ def sendmail(self, recipients, subject='', body='', attachments=None,
if type(bcc) == str:
outer['Bcc'] = bcc
toaddrs.append(bcc)
elif type(bcc) == list:
elif isinstance(bcc, list):
outer['Bcc'] = self._COMMA_SPLITTER.join(bcc)
toaddrs.extend(bcc)
else:
Expand Down
68 changes: 65 additions & 3 deletions cup/services/msgbroker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,33 @@
:description:
Msg Broker Service. Every component of a process can produce_msg
"""
from cup import decorators
# from cup import decorators


MSG_ERROR_DISK_ERROR = 1

__all__ = ['BrokerCenter']


MSG_TYPE_FATAL = 0
MSG_TYPE_WARN = 1


class BaseBroker(object):
"""
Base Broker for a system
"""
_name = None
def __init__(self, name):
self._name = name


@decorators.Singleton
class BrokerCenter(BaseBroker):
"""
Errmsg broker center
"""
def __init__(self, name):
self._name = name
BaseBroker.__init__(self, name)

def produce_msg(self, msg_type, extra_info, error):
"""register msg"""
Expand All @@ -42,4 +48,60 @@ def comsume_msg(self, msg_type):
"""


class SystemErrmsgBroker(BrokerCenter):
"""
system errmsg broker, you can use it to determine whether
exiting from the system is on the way
"""
def __init__(self, name):
BrokerCenter.__init__(self, name)

def need_stop(self, path):
"""
return True if the system registered on
the path needs to stop immediately
"""

def fatal_alert(self, path, msg, need_stop=True):
"""fatal alert systems"""

def warnning_alert(self, path, msg):
"""
warnning alert
"""

def register_msg(self, path, msgtype, msg):
"""register msg into the system"""

def get_fatal_alerts(self, path):
"""
get fatal alerts of the current running round
"""

def clean_data(self, path, exclude_msgtypes=None):
"""
clean data of the remaining data
"""

def register_wakeup(self, path, msgtype, alert_cap_num, callfunc):
"""
register wakeups.
:param alert_cap_num:
If alert_cap_num is 0, whenever a msg of msgtype is received,
the callfunc will be called.
:param msgtype:
[msgbroker.FATAL|msgbroker.WARN]
"""

def _wakeup(self, path, msgtype, alert_cap_num, callfunc):
"""
wake up callfunc
"""

def register_msgtype_callback(self, path, msg_type, callback_func):
"""
register msgtype with callback functions
"""

# vi:set tw=0 ts=4 sw=4 nowrap fdm=indent

0 comments on commit 6c2807e

Please sign in to comment.