Back to index

python3.2  3.2.2
Classes | Functions | Variables
smtpd Namespace Reference

Classes

class  Devnull
class  SMTPChannel
class  SMTPServer
class  DebuggingServer
class  PureProxy
class  MailmanProxy
class  Options

Functions

def usage
def parseargs

Variables

list __all__ = ["SMTPServer","DebuggingServer","PureProxy","MailmanProxy"]
list program = sys.argv[0]
string __version__ = 'Python SMTP proxy version 0.2'
tuple DEBUGSTREAM = Devnull()
string NEWLINE = '\n'
string EMPTYSTRING = ''
string COMMASPACE = ', '
tuple options = parseargs()
tuple nobody = pwd.getpwnam('nobody')
 classname = options.classname
tuple lastdot = classname.rfind(".")
tuple mod = __import__(classname[:lastdot], globals(), locals(), [""])
tuple class_ = getattr(mod, classname)
tuple proxy

Function Documentation

def smtpd.parseargs ( )

Definition at line 621 of file smtpd.py.

00621 
00622 def parseargs():
00623     global DEBUGSTREAM
00624     try:
00625         opts, args = getopt.getopt(
00626             sys.argv[1:], 'nVhc:d',
00627             ['class=', 'nosetuid', 'version', 'help', 'debug'])
00628     except getopt.error as e:
00629         usage(1, e)
00630 
00631     options = Options()
00632     for opt, arg in opts:
00633         if opt in ('-h', '--help'):
00634             usage(0)
00635         elif opt in ('-V', '--version'):
00636             print(__version__, file=sys.stderr)
00637             sys.exit(0)
00638         elif opt in ('-n', '--nosetuid'):
00639             options.setuid = 0
00640         elif opt in ('-c', '--class'):
00641             options.classname = arg
00642         elif opt in ('-d', '--debug'):
00643             DEBUGSTREAM = sys.stderr
00644 
00645     # parse the rest of the arguments
00646     if len(args) < 1:
00647         localspec = 'localhost:8025'
00648         remotespec = 'localhost:25'
00649     elif len(args) < 2:
00650         localspec = args[0]
00651         remotespec = 'localhost:25'
00652     elif len(args) < 3:
00653         localspec = args[0]
00654         remotespec = args[1]
00655     else:
00656         usage(1, 'Invalid arguments: %s' % COMMASPACE.join(args))
00657 
00658     # split into host/port pairs
00659     i = localspec.find(':')
00660     if i < 0:
00661         usage(1, 'Bad local spec: %s' % localspec)
00662     options.localhost = localspec[:i]
00663     try:
00664         options.localport = int(localspec[i+1:])
00665     except ValueError:
00666         usage(1, 'Bad local port: %s' % localspec)
00667     i = remotespec.find(':')
00668     if i < 0:
00669         usage(1, 'Bad remote spec: %s' % remotespec)
00670     options.remotehost = remotespec[:i]
00671     try:
00672         options.remoteport = int(remotespec[i+1:])
00673     except ValueError:
00674         usage(1, 'Bad remote port: %s' % remotespec)
00675     return options
00676 
00677 


Here is the call graph for this function:

def smtpd.usage (   code,
  msg = '' 
)

Definition at line 100 of file smtpd.py.

00100 
00101 def usage(code, msg=''):
00102     print(__doc__ % globals(), file=sys.stderr)
00103     if msg:
00104         print(msg, file=sys.stderr)
00105     sys.exit(code)
00106 
00107 


Here is the caller graph for this function:


Variable Documentation

list smtpd.__all__ = ["SMTPServer","DebuggingServer","PureProxy","MailmanProxy"]

Definition at line 82 of file smtpd.py.

string smtpd.__version__ = 'Python SMTP proxy version 0.2'

Definition at line 85 of file smtpd.py.

Definition at line 701 of file smtpd.py.

list smtpd.classname = options.classname

Definition at line 694 of file smtpd.py.

Definition at line 96 of file smtpd.py.

Definition at line 93 of file smtpd.py.

Definition at line 95 of file smtpd.py.

tuple smtpd.lastdot = classname.rfind(".")

Definition at line 696 of file smtpd.py.

tuple smtpd.mod = __import__(classname[:lastdot], globals(), locals(), [""])

Definition at line 697 of file smtpd.py.

Definition at line 94 of file smtpd.py.

Definition at line 687 of file smtpd.py.

Definition at line 679 of file smtpd.py.

Definition at line 84 of file smtpd.py.

tuple smtpd.proxy
Initial value:
00001 class_((options.localhost, options.localport),
00002                    (options.remotehost, options.remoteport))

Definition at line 702 of file smtpd.py.