Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1887)

Unified Diff: third_party/twisted_8_1/twisted/mail/relay.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/twisted_8_1/twisted/mail/relay.py
diff --git a/third_party/twisted_8_1/twisted/mail/relay.py b/third_party/twisted_8_1/twisted/mail/relay.py
deleted file mode 100644
index 5fbf48f4ddf2a164797e6eb35ea5fe332cbfd949..0000000000000000000000000000000000000000
--- a/third_party/twisted_8_1/twisted/mail/relay.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# -*- test-case-name: twisted.mail.test.test_mail -*-
-# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-
-"""Support for relaying mail for twisted.mail"""
-
-from twisted.mail import smtp
-from twisted.python import log
-from twisted.internet.address import UNIXAddress
-
-import os
-
-try:
- import cPickle as pickle
-except ImportError:
- import pickle
-
-class DomainQueuer:
- """An SMTP domain which add messages to a queue intended for relaying."""
-
- def __init__(self, service, authenticated=False):
- self.service = service
- self.authed = authenticated
-
- def exists(self, user):
- """Check whether we will relay
-
- Call overridable willRelay method
- """
- if self.willRelay(user.dest, user.protocol):
- # The most cursor form of verification of the addresses
- orig = filter(None, str(user.orig).split('@', 1))
- dest = filter(None, str(user.dest).split('@', 1))
- if len(orig) == 2 and len(dest) == 2:
- return lambda: self.startMessage(user)
- raise smtp.SMTPBadRcpt(user)
-
- def willRelay(self, address, protocol):
- """Check whether we agree to relay
-
- The default is to relay for all connections over UNIX
- sockets and all connections from localhost.
- """
- peer = protocol.transport.getPeer()
- return self.authed or isinstance(peer, UNIXAddress) or peer.host == '127.0.0.1'
-
- def startMessage(self, user):
- """Add envelope to queue and returns ISMTPMessage."""
- queue = self.service.queue
- envelopeFile, smtpMessage = queue.createNewMessage()
- try:
- log.msg('Queueing mail %r -> %r' % (str(user.orig), str(user.dest)))
- pickle.dump([str(user.orig), str(user.dest)], envelopeFile)
- finally:
- envelopeFile.close()
- return smtpMessage
-
-class RelayerMixin:
-
- # XXX - This is -totally- bogus
- # It opens about a -hundred- -billion- files
- # and -leaves- them open!
-
- def loadMessages(self, messagePaths):
- self.messages = []
- self.names = []
- for message in messagePaths:
- fp = open(message+'-H')
- try:
- messageContents = pickle.load(fp)
- finally:
- fp.close()
- fp = open(message+'-D')
- messageContents.append(fp)
- self.messages.append(messageContents)
- self.names.append(message)
-
- def getMailFrom(self):
- if not self.messages:
- return None
- return self.messages[0][0]
-
- def getMailTo(self):
- if not self.messages:
- return None
- return [self.messages[0][1]]
-
- def getMailData(self):
- if not self.messages:
- return None
- return self.messages[0][2]
-
- def sentMail(self, code, resp, numOk, addresses, log):
- """Since we only use one recipient per envelope, this
- will be called with 0 or 1 addresses. We probably want
- to do something with the error message if we failed.
- """
- if code in smtp.SUCCESS:
- # At least one, i.e. all, recipients successfully delivered
- os.remove(self.names[0]+'-D')
- os.remove(self.names[0]+'-H')
- del self.messages[0]
- del self.names[0]
-
-class SMTPRelayer(RelayerMixin, smtp.SMTPClient):
- def __init__(self, messagePaths, *args, **kw):
- smtp.SMTPClient.__init__(self, *args, **kw)
- self.loadMessages(messagePaths)
-
-class ESMTPRelayer(RelayerMixin, smtp.ESMTPClient):
- def __init__(self, messagePaths, *args, **kw):
- smtp.ESMTPClient.__init__(self, *args, **kw)
- self.loadMessages(messagePaths)
« no previous file with comments | « third_party/twisted_8_1/twisted/mail/protocols.py ('k') | third_party/twisted_8_1/twisted/mail/relaymanager.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698