diff --git a/.gitignore b/.gitignore index 3683826..b451985 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ build.sh .DS_Store *.*~ *.log - cup/net/async/msgcenter_dict.py - cup.tar +tmp diff --git a/ChangeLog b/ChangeLog index 86fd5fb..de1d1e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/cup/mail.py b/cup/mail.py index c148000..3f55475 100644 --- a/cup/mail.py +++ b/cup/mail.py @@ -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: @@ -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: diff --git a/cup/services/msgbroker.py b/cup/services/msgbroker.py index 3cc45e1..f5b1b91 100644 --- a/cup/services/msgbroker.py +++ b/cup/services/msgbroker.py @@ -11,7 +11,7 @@ :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 @@ -19,19 +19,25 @@ __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""" @@ -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