Skip to content

Commit

Permalink
Merge postfix-main-3717
Browse files Browse the repository at this point in the history
Author: cary, thijs
Reviewer: exarkun
Fixes: twisted#3717

Move the `__main__` out of `twisted/protocols/postfix.py` into a separate example
script.


git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@26573 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
  • Loading branch information
exarkun committed Mar 31, 2009
1 parent 52449ca commit 7f89549
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
1 change: 1 addition & 0 deletions doc/core/examples/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<li><a href="gpsfix.py">gpsfix.py</a> - example using the SerialPort transport and GPS
protocols to display fix data as it is received from the device</li>
<li><a href="wxacceptance.py">wxacceptance.py</a> - acceptance tests for wxreactor</li>
<li><a href="postfix.py">postfix.py</a> - test application for PostfixTCPMapServer</li>
</ul>

</body>
Expand Down
29 changes: 29 additions & 0 deletions doc/core/examples/postfix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2009 Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Test app for PostfixTCPMapServer.
Call with parameters KEY1=VAL1 KEY2=VAL2 ...
"""

import sys

from twisted.internet import reactor
from twisted.protocols import postfix
from twisted.python import log

log.startLogging(sys.stdout)

d = {}
for arg in sys.argv[1:]:
try:
k,v = arg.split('=', 1)
except ValueError:
k = arg
v = ''
d[k] = v

f = postfix.PostfixTCPMapDictServerFactory(d)
port = reactor.listenTCP(4242, f, interface='127.0.0.1')
reactor.run()
32 changes: 6 additions & 26 deletions twisted/protocols/postfix.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
# -*- test-case-name: twisted.test.test_postfix -*-
#
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
# Copyright (c) 2001-2009 Twisted Matrix Laboratories.
# See LICENSE for details.

#

"""Postfix mail transport agent related protocols."""
"""
Postfix mail transport agent related protocols.
"""

import sys
import UserDict
import urllib

# Twisted imports
from twisted.protocols import basic
from twisted.protocols import policies
from twisted.internet import protocol, defer
from twisted.python import log
import UserDict
import urllib

# urllib's quote functions just happen to match
# the postfix semantics.

def quote(s):
return urllib.quote(s)

Expand Down Expand Up @@ -113,20 +110,3 @@ def __init__(self, data=None):

def get(self, key):
return defer.succeed(self.data.get(key))

if __name__ == '__main__':
"""Test app for PostfixTCPMapServer. Call with parameters
KEY1=VAL1 KEY2=VAL2 ..."""
from twisted.internet import reactor
log.startLogging(sys.stdout)
d = {}
for arg in sys.argv[1:]:
try:
k,v = arg.split('=', 1)
except ValueError:
k = arg
v = ''
d[k]=v
f=PostfixTCPMapDictServerFactory(d)
port = reactor.listenTCP(4242, f, interface='127.0.0.1')
reactor.run()

0 comments on commit 7f89549

Please sign in to comment.