def _dispose(self, mlist, msg, msgdata): # Make sure we have the most up-to-date state mlist.Load() if not msgdata.get('prepped'): prepare_message(mlist, msg, msgdata) try: # Flatten the message object, sticking it in a StringIO object fp = StringIO(msg.as_string()) conn = None try: try: nntp_host, nntp_port = Utils.nntpsplit(mlist.nntp_host) conn = nntplib.NNTP(nntp_host, nntp_port, readermode=True, user=mm_cfg.NNTP_USERNAME, password=mm_cfg.NNTP_PASSWORD) conn.post(fp) except nntplib.error_temp as e: syslog('error', '(NNTPDirect) NNTP error for list "%s": %s', mlist.internal_name(), e) except socket.error as e: syslog('error', '(NNTPDirect) socket error for list "%s": %s', mlist.internal_name(), e) finally: if conn: conn.quit() except Exception as e: # Some other exception occurred, which we definitely did not # expect, so set this message up for requeuing. self._log(e) return True return False
def _dispose(self, mlist, msg, msgdata): # Make sure we have the most up-to-date state mlist.Load() if not msgdata.get('prepped'): prepare_message(mlist, msg, msgdata) try: # Flatten the message object, sticking it in a StringIO object fp = StringIO(msg.as_string()) conn = None try: try: nntp_host, nntp_port = Utils.nntpsplit(mlist.nntp_host) conn = nntplib.NNTP(nntp_host, nntp_port, readermode=True, user=mm_cfg.NNTP_USERNAME, password=mm_cfg.NNTP_PASSWORD) conn.post(fp) except nntplib.error_temp, e: syslog('error', '(NNTPDirect) NNTP error for list "%s": %s', mlist.internal_name(), e) except socket.error, e: syslog('error', '(NNTPDirect) socket error for list "%s": %s', mlist.internal_name(), e) finally: if conn: conn.quit()