[python-postman] bump up to postman 0.6.0. add logging patch.
Brett Lentz
wakko666 at fedoraproject.org
Tue Nov 8 14:49:32 UTC 2011
commit 9f6595915fd9ed99c145d040b9ec621fe7a7581d
Author: Brett Lentz <blentz at redhat.com>
Date: Tue Nov 8 09:49:08 2011 -0500
bump up to postman 0.6.0. add logging patch.
.gitignore | 1 +
postman_logging.patch | 211 ++++++++++++++++++++++++++++++++++++++++++++++++
postman_sanitize.patch | 67 ---------------
python-postman.spec | 10 ++-
sources | 2 +-
5 files changed, 220 insertions(+), 71 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 122b63e..201e38d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/postman-0.5.2.tar.gz
+/postman-0.6.0.tar.gz
diff --git a/postman_logging.patch b/postman_logging.patch
new file mode 100644
index 0000000..d0b3951
--- /dev/null
+++ b/postman_logging.patch
@@ -0,0 +1,211 @@
+--- postman/__main__.py.orig 2011-11-08 09:40:20.562643953 -0500
++++ postman/__main__.py 2011-11-08 09:40:31.067641953 -0500
+@@ -1,4 +1,5 @@
+ import argparse
++import logging
+ import re
+ import sys
+
+@@ -6,24 +7,34 @@
+
+ from postman import __version__
+
+-legal_headers = [ "Accept-Language", "Bcc", "Cc", "Comments", "Content-Type",
+- "Content-Transfer-Encoding", "Content-ID", "Content-Description",
++syslog_handler = logging.handlers.SysLogHandler(address='/dev/log')
++syslog_handler.setFormatter(logging.Formatter('%(name)s %(levelname)s: %(message)s'))
++
++log = logging.getLogger(__name__)
++log.addHandler(syslog_handler)
++log.setLevel(logging.INFO)
++
++stdout_handler = logging.StreamHandler(sys.stdout)
++stdout_handler.setFormatter(logging.Formatter('%(message)s'))
++
++out = logging.getLogger(__name__)
++out.addHandler(stdout_handler)
++out.setLevel(logging.INFO)
++
++log.debug("Logging started.")
++
++legal_headers = [ "Accept-Language", "Bcc", "Cc", "Comments", "Content-Type",
++ "Content-Transfer-Encoding", "Content-ID", "Content-Description",
+ "Content-Disposition", "Content-Language", "Date", "DKIM-Signature",
+- "DomainKey-Signature From", "In-Reply-To", "Keywords", "List-Archive",
+- "List-Help", "List-Id", "List-Owner", "List-Post", "List-Subscribe",
++ "DomainKey-Signature", "From", "In-Reply-To", "Keywords", "List-Archive",
++ "List-Help", "List-Id", "List-Owner", "List-Post", "List-Subscribe",
+ "List-Unsubscribe", "Message-Id", "MIME-Version", "Received", "References",
+- "Reply-To", "Return-Path", "Sender", "Subject", "Thread-Index",
++ "Reply-To", "Return-Path", "Sender", "Subject", "Thread-Index",
+ "Thread-Topic", "To", "User-Agent" ]
+
+-def out(msg, args):
+- if args.verbose:
+- sys.stdout.write("%s\n" % msg)
+- sys.stdout.flush()
+-
+ def sanitize(args, msg):
+- """
+- Transform any headers SES disallows in to X-Headers.
+-
++ """ Transform any headers SES disallows in to X-Headers.
++
+ Sanitize method adapted from this Perl snippet:
+ http://www.evanhoffman.com/evan/2011/05/16/amazon-ses-illegal-header-errors/
+ """
+@@ -43,83 +54,86 @@
+ line = "X-%s" % line
+ cleanmsg += line
+ return cleanmsg
+-
++
+ def cmd_send(args):
+ ses = boto.connect_ses()
+- out("Sending mail to: %s" % ", ".join(args.destinations), args)
++ log.info("Sending mail to: %s" % ", ".join(args.destinations))
+ msg = sys.stdin.read()
+ if args.sanitize:
+ msg = sanitize(args, msg)
+- r = ses.send_raw_email(msg, args.f, args.destinations)
+- if r.get("SendRawEmailResponse", {}).get("SendRawEmailResult", {}).get("MessageId"):
+- out("OK", args)
+- else:
+- out("ERROR: %s" % r, args)
+-
++ log.debug("Message is: %s" % msg)
++ try:
++ r = ses.send_raw_email(msg, args.f, args.destinations)
++ if r.get("SendRawEmailResponse", {}).get("SendRawEmailResult", {}).get("MessageId"):
++ log.info("OK")
++ else:
++ log.error("ERROR: %s" % r)
++ except boto.exception.BotoServerError as e:
++ log.error("ERROR: %s" % e)
+
+ def cmd_verify(args):
+ ses = boto.connect_ses()
+ for email in args.email:
+ ses.verify_email_address(email)
+- out("Verification for %s sent." % email, args)
++ log.info("Verification for %s sent." % email)
+
+
+ def cmd_list_verified(args):
+ ses = boto.connect_ses()
+ args.verbose = True
+-
++
+ addresses = ses.list_verified_email_addresses()
+ addresses = addresses["ListVerifiedEmailAddressesResponse"]
+ addresses = addresses["ListVerifiedEmailAddressesResult"]
+ addresses = addresses["VerifiedEmailAddresses"]
+-
++
+ if not addresses:
+- out("No addresses are verified on this account.", args)
++ log.warn("No addresses are verified on this account.")
+ return
+-
++
+ for address in addresses:
+- out(address, args)
++ log.info(address)
+
+
+ def cmd_show_quota(args):
+ ses = boto.connect_ses()
+ args.verbose= True
+-
++
+ data = ses.get_send_quota()["GetSendQuotaResponse"]["GetSendQuotaResult"]
+- out("Max 24 Hour Send: %s" % data["Max24HourSend"], args)
+- out("Sent Last 24 Hours: %s" % data["SentLast24Hours"], args)
+- out("Max Send Rate: %s" % data["MaxSendRate"], args)
++ out.info("Max 24 Hour Send: %s" % data["Max24HourSend"])
++ out.info("Sent Last 24 Hours: %s" % data["SentLast24Hours"])
++ out.info("Max Send Rate: %s" % data["MaxSendRate"])
+
+
+ def cmd_show_stats(args):
+ ses = boto.connect_ses()
+ args.verbose = True
+-
++
+ data = ses.get_send_statistics()
+ data = data["GetSendStatisticsResponse"]["GetSendStatisticsResult"]
+ for datum in data["SendDataPoints"]:
+- out("Complaints: %s" % datum["Complaints"], args)
+- out("Timestamp: %s" % datum["Timestamp"], args)
+- out("DeliveryAttempts: %s" % datum["DeliveryAttempts"], args)
+- out("Bounces: %s" % datum["Bounces"], args)
+- out("Rejects: %s" % datum["Rejects"], args)
+- out("", args)
++ out.info("Complaints: %s" % datum["Complaints"])
++ out.info("Timestamp: %s" % datum["Timestamp"])
++ out.info("DeliveryAttempts: %s" % datum["DeliveryAttempts"])
++ out.info("Bounces: %s" % datum["Bounces"])
++ out.info("Rejects: %s" % datum["Rejects"])
++ out.info("")
+
+
+ def cmd_delete_verified(args):
+ ses = boto.connect_ses()
+ for email in args.email:
+ ses.delete_verified_email_address(email_address=email)
+- out("Deleted %s" % email, args)
++ out.info("Deleted %s" % email)
+
+
+ def main():
+ parser = argparse.ArgumentParser(prog="postman", description="send an email via Amazon SES")
+ parser.add_argument("--version", action="version", version="%%(prog)s %s" % __version__)
+ parser.add_argument("--verbose", action="store_true")
+-
++
+ command_parsers = parser.add_subparsers(dest="command")
+-
++
+ # cmd: send
+ parser_send = command_parsers.add_parser("send")
+ parser_send.add_argument("-f",
+@@ -128,28 +142,32 @@
+ help="Sanitize headers. Convert illegal headers to X-Headers.")
+ parser_send.add_argument("destinations", metavar="TO", type=str, nargs="+",
+ help="a list of email addresses to deliver message to")
+-
++
+ # cmd: verify
+ parser_send = command_parsers.add_parser("verify")
+ parser_send.add_argument("email", nargs="+",
+ help="an email address to verify for sending from")
+-
++
+ # cmd: list_verified
+ command_parsers.add_parser("list_verified")
+-
++
+ # cmd: show_quota
+ command_parsers.add_parser("show_quota")
+-
++
+ # cmd: show_stats
+ command_parsers.add_parser("show_stats")
+-
++
+ # cmd: delete_verified
+ parser_delete = command_parsers.add_parser("delete_verified")
+ parser_delete.add_argument("email", nargs="+",
+ help="verified email addresses that will be deleted from verification list")
+-
++
+ args = parser.parse_args()
+-
++
++ if args.verbose:
++ log.setLevel(logging.DEBUG)
++ out.setLevel(logging.DEBUG)
++
+ {
+ "send": cmd_send,
+ "verify": cmd_verify,
diff --git a/python-postman.spec b/python-postman.spec
index da9e2e7..dbb7011 100644
--- a/python-postman.spec
+++ b/python-postman.spec
@@ -5,8 +5,8 @@
%global pkgname postman
Name: python-%{pkgname}
-Version: 0.5.2
-Release: 4%{?dist}
+Version: 0.6.0
+Release: 1%{?dist}
Summary: Postman is a command line utility for working with Amazon SES
Group: Applications/Internet
@@ -14,7 +14,7 @@ License: MIT
URL: http://pypi.python.org/pypi/%{pkgname}
Source0: http://pypi.python.org/packages/source/p/%{pkgname}/%{pkgname}-%{version}.tar.gz
Patch0: postman_fixdeps.patch
-Patch1: postman_sanitize.patch
+Patch1: postman_logging.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
@@ -76,6 +76,10 @@ rm -rf %{buildroot}
%{_mandir}/man5/*
%changelog
+* Tue Nov 8 2011 Brett Lentz <blentz at redhat.com> - 0.6.0-1
+- Update to 0.6.0, upstreamed --sanitize patch.
+- Add patch to support better logging.
+
* Wed Oct 26 2011 Brett Lentz <blentz at redhat.com> - 0.5.2-4
- Add --sanitize flag to allow working around SES illegal headers issues.
diff --git a/sources b/sources
index 95ec9cd..baf67fd 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-c44e5c0fd9b0ca96f8b6f8053357b1e0 postman-0.5.2.tar.gz
+304c0d6a6dc8c355f4c1aa9437ea18f4 postman-0.6.0.tar.gz
More information about the scm-commits
mailing list