flush= not supported until python-3.3

This commit is contained in:
Stuart D. Gathman
2016-07-26 09:58:30 -04:00
parent 76eb93223c
commit 999a446484
5 changed files with 14 additions and 9 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ class TestBase(object):
def log(self,*msg):
for i in msg: print(i,file=self.logfp,end=None)
print(file=self.logfp,flush=True)
print(file=self.logfp)
## Set a macro value.
# These are retrieved by the %milter with getsymval.
+3 -2
View File
@@ -2,6 +2,7 @@
# Internal is defined as using one of a list of internal top level domains.
# This code is open-source on the same terms as Python.
from __future__ import print_function
import Milter
import time
import sys
@@ -68,12 +69,12 @@ def main():
timeout = 600
# Register to have the Milter factory create instances of your class:
Milter.factory = NoMixMilter
print "%s milter startup" % time.strftime('%Y%b%d %H:%M:%S')
print("%s milter startup" % time.strftime('%Y%b%d %H:%M:%S'))
sys.stdout.flush()
Milter.runmilter("nomixfilter",socketname,timeout)
logq.put(None)
bt.join()
print "%s nomix milter shutdown" % time.strftime('%Y%b%d %H:%M:%S')
print("%s nomix milter shutdown" % time.strftime('%Y%b%d %H:%M:%S'))
if __name__ == "__main__":
main()
+4 -2
View File
@@ -136,7 +136,8 @@ def background():
end=None)
# 2005Oct13 02:34:11 [1] msg1 msg2 msg3 ...
for i in msg: print(i,end=None)
print(flush=True)
print()
sys.stdout.flush()
## ===
@@ -151,7 +152,8 @@ def main():
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
print("%s milter startup" % time.strftime('%Y%b%d %H:%M:%S'),flush=True)
print("%s milter startup" % time.strftime('%Y%b%d %H:%M:%S'))
sys.stdout.flush()
Milter.runmilter("pythonfilter",socketname,timeout)
logq.put(None)
bt.join()
+3 -2
View File
@@ -23,7 +23,7 @@ class sampleMilter(Milter.Milter):
def log(self,*msg):
print("%s [%d]" % (strftime('%Y%b%d %H:%M:%S'),self.id),end=None)
for i in msg: print(i,end=None)
print(flush=True)
print()
def __init__(self):
self.tempname = None
@@ -177,6 +177,7 @@ O InputMailFilters=pythonfilter
Xpythonfilter, S=local:%s
See the sendmail README for libmilter.
sample milter startup""" % socketname,flush=True)
sample milter startup""" % socketname)
sys.stdout.flush()
Milter.runmilter("pythonfilter",socketname,240)
print("sample milter shutdown")
+3 -2
View File
@@ -26,6 +26,7 @@
# Revision 1.20 2004/11/20 16:38:17 stuart
# Add rcs log
#
from __future__ import print_function
import unittest
import mime
import socket
@@ -188,7 +189,7 @@ class MimeTestCase(unittest.TestCase):
script = "<script lang=javascript> Dangerous script </script>"
filter.feed(msg + script)
filter.close()
#print result.getvalue()
#print(result.getvalue())
self.failUnless(result.getvalue() == msg + filter.msg)
def suite(): return unittest.makeSuite(MimeTestCase,'test')
@@ -201,4 +202,4 @@ if __name__ == '__main__':
fp = open(fname,'r')
msg = mime.message_from_file(fp)
mime.defang(msg,scan_zip=True)
print msg.as_string()
print(msg.as_string())