tests/dummysmtpd.py
branchstable
changeset 43306 59338f956109
parent 43076 2372284d9457
child 45830 c102b704edb5
--- a/tests/dummysmtpd.py	Wed Oct 02 12:20:36 2019 -0400
+++ b/tests/dummysmtpd.py	Mon Oct 21 11:09:48 2019 -0400
@@ -18,10 +18,12 @@
     ui as uimod,
 )
 
+
 def log(msg):
     sys.stdout.write(msg)
     sys.stdout.flush()
 
+
 class dummysmtpserver(smtpd.SMTPServer):
     def __init__(self, localaddr):
         smtpd.SMTPServer.__init__(self, localaddr, remoteaddr=None)
@@ -38,6 +40,7 @@
         # the expected way, and the server is available for subsequent requests.
         traceback.print_exc()
 
+
 class dummysmtpsecureserver(dummysmtpserver):
     def __init__(self, localaddr, certfile):
         dummysmtpserver.__init__(self, localaddr)
@@ -58,25 +61,30 @@
             return
         smtpd.SMTPChannel(self, conn, addr)
 
+
 def run():
     try:
         asyncore.loop()
     except KeyboardInterrupt:
         pass
 
+
 def _encodestrsonly(v):
     if isinstance(v, type(u'')):
         return v.encode('ascii')
     return v
 
+
 def bytesvars(obj):
     unidict = vars(obj)
     bd = {k.encode('ascii'): _encodestrsonly(v) for k, v in unidict.items()}
     if bd[b'daemon_postexec'] is not None:
         bd[b'daemon_postexec'] = [
-            _encodestrsonly(v) for v in bd[b'daemon_postexec']]
+            _encodestrsonly(v) for v in bd[b'daemon_postexec']
+        ]
     return bd
 
+
 def main():
     op = optparse.OptionParser()
     op.add_option('-d', '--daemon', action='store_true')
@@ -92,6 +100,7 @@
         op.error('--certificate must be specified')
 
     addr = (opts.address, opts.port)
+
     def init():
         if opts.tls == 'none':
             dummysmtpserver(addr)
@@ -100,9 +109,13 @@
         log('listening at %s:%d\n' % addr)
 
     server.runservice(
-        bytesvars(opts), initfn=init, runfn=run,
-        runargs=[pycompat.sysexecutable,
-                 pycompat.fsencode(__file__)] + pycompat.sysargv[1:])
+        bytesvars(opts),
+        initfn=init,
+        runfn=run,
+        runargs=[pycompat.sysexecutable, pycompat.fsencode(__file__)]
+        + pycompat.sysargv[1:],
+    )
+
 
 if __name__ == '__main__':
     main()