[calm - Cygwin server-side packaging maintenance script] branch master, updated. 20190530-47-gac394d6

jturney@sourceware.org jturney@sourceware.org
Fri Jul 5 11:06:00 GMT 2019




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=ac394d62193a22271554029717e05a9fa1207a88

commit ac394d62193a22271554029717e05a9fa1207a88
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Fri Jul 5 12:04:05 2019 +0100

    Fix package name in json dump

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=de8988118911ddbbd2d2e8488e83ed0d64e4c031

commit de8988118911ddbbd2d2e8488e83ed0d64e4c031
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Fri Mar 18 20:03:37 2016 +0000

    Add a manual test script for sending log mail

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=356b1abeebad05dd0f8597bf12169f46053bc2da

commit 356b1abeebad05dd0f8597bf12169f46053bc2da
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Thu Jul 4 23:07:09 2019 +0100

    Send mail using /usr/sbin/sendmail, rather than SMTP

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=cf2dba461216a3ef4c0b39e5d9829a505204434d

commit cf2dba461216a3ef4c0b39e5d9829a505204434d
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Thu Jul 4 20:44:47 2019 +0100

    Fix flake8 issues


Diff:
---
 calm/buffering_smtp_handler.py |   17 +++++------------
 calm/calm.py                   |    7 +++----
 calm/hint.py                   |    2 +-
 calm/movelist.py               |    3 ++-
 calm/package.py                |    5 +++--
 calm/pkg2html.py               |    1 -
 calm/spelling.py               |    2 +-
 calm/uploads.py                |    1 -
 pep8                           |    2 +-
 test/mail-test                 |   22 ++++++++++++++++++++++
 10 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/calm/buffering_smtp_handler.py b/calm/buffering_smtp_handler.py
index 0867c91..9d347df 100644
--- a/calm/buffering_smtp_handler.py
+++ b/calm/buffering_smtp_handler.py
@@ -21,10 +21,11 @@
 #
 
 
-import logging
-import logging.handlers
 import email.message
 import email.utils
+import logging
+import logging.handlers
+import subprocess
 
 from . import common_constants
 
@@ -84,16 +85,8 @@ class BufferingSMTPHandler(logging.handlers.BufferingHandler):
                 print(msg)
                 print('-' * 40)
             elif len(self.toaddrs) > 0:
-                try:
-                    import smtplib
-                    port = self.mailport
-                    if not port:
-                        port = smtplib.SMTP_PORT
-                    smtp = smtplib.SMTP(self.mailhost, port)
-                    smtp.send_message(m)
-                    smtp.quit()
-                except ImportError:
-                    self.handleError(self.buffer[0])  # first record
+                with subprocess.Popen(['/usr/sbin/sendmail', '-t', '-oi'], stdin=subprocess.PIPE) as p:
+                    p.communicate(m.as_bytes())
 
             self.buffer = []
 
diff --git a/calm/calm.py b/calm/calm.py
index 28e15e3..c68b12d 100755
--- a/calm/calm.py
+++ b/calm/calm.py
@@ -52,7 +52,6 @@
 # write setup.ini file
 #
 
-from collections import defaultdict
 from contextlib import ExitStack
 import argparse
 import logging
@@ -142,7 +141,7 @@ def process_uploads(args, state):
         m = mlist[name]
 
         # also send a mail to each maintainer about their packages
-        with mail_logs(args.email, toaddrs=m.email, subject='%s for %s' % (state.subject, name), thresholdLevel=logging.INFO) as maint_email:
+        with mail_logs(args.email, toaddrs=m.email, subject='%s for %s' % (state.subject, name), thresholdLevel=logging.INFO) as maint_email:  # noqa: F841
 
             # for each arch and noarch
             scan_result = {}
@@ -272,7 +271,7 @@ def process_uploads(args, state):
 
 def process(args, state):
     # send one email per run to leads, if any errors occurred
-    with mail_logs(args.email, toaddrs=args.email, subject='%s' % (state.subject), thresholdLevel=logging.ERROR) as leads_email:
+    with mail_logs(args.email, toaddrs=args.email, subject='%s' % (state.subject), thresholdLevel=logging.ERROR) as leads_email:  # noqa: F841
         if args.dryrun:
             logging.warning("--dry-run is in effect, nothing will really be done")
 
@@ -593,7 +592,7 @@ def do_daemon(args, state):
                 # cancel any pending alarm
                 signal.alarm(0)
         except Exception as e:
-            with mail_logs(args.email, toaddrs=args.email, subject='calm stopping due to unhandled exception', thresholdLevel=logging.ERROR) as leads_email:
+            with mail_logs(args.email, toaddrs=args.email, subject='calm stopping due to unhandled exception', thresholdLevel=logging.ERROR) as leads_email:  # noqa: F841
                 logging.error("exception %s" % (type(e).__name__), exc_info=True)
             irk.irk("calm daemon stopped due to unhandled exception")
         else:
diff --git a/calm/hint.py b/calm/hint.py
index 5b050a7..608cc96 100755
--- a/calm/hint.py
+++ b/calm/hint.py
@@ -363,7 +363,7 @@ def main(args):
     status = 0
 
     for fn in args.files:
-        hints = hint_file_parse(fn, setup)
+        hints = hint_file_parse(fn, pvr)
 
         if args.verbose > 1:
             print(hints)
diff --git a/calm/movelist.py b/calm/movelist.py
index bf6268e..c7bdde8 100644
--- a/calm/movelist.py
+++ b/calm/movelist.py
@@ -23,6 +23,7 @@
 
 import logging
 import os
+import shutil
 
 from collections import defaultdict
 from . import utils
@@ -92,7 +93,7 @@ class MoveList(object):
         return i
 
     # copy the files in a movelist
-    def copy(args, fromdir, todir):
+    def copy(self, args, fromdir, todir):
         for p in sorted(self.movelist):
             logging.debug("mkdir %s" % os.path.join(todir, p))
             if not args.dryrun:
diff --git a/calm/package.py b/calm/package.py
index f73eb28..ea2291e 100755
--- a/calm/package.py
+++ b/calm/package.py
@@ -47,7 +47,8 @@ from . import maintainers
 from . import past_mistakes
 
 
-# kinds of packages @unique
+# kinds of packages
+@unique
 class Kind(Enum):
     binary = 1  # aka 'install'
     source = 2
@@ -1171,7 +1172,7 @@ def write_repo_json(args, packages, f):
             versions[key] = versions.get(key, []) + [vr]
 
         d = {
-            'name': pn,
+            'name': po.orig_name,
             'versions': versions,
             'summary': po.version_hints[bv]['sdesc'].strip('"'),
             'subpackages': [{'name': sp, 'categories': package(sp).version_hints[package(sp).best_version].get('category', '').split()} for sp in po.is_used_by],
diff --git a/calm/pkg2html.py b/calm/pkg2html.py
index d61d5db..2c14933 100755
--- a/calm/pkg2html.py
+++ b/calm/pkg2html.py
@@ -267,7 +267,6 @@ def update_package_listings(args, packages):
                             def tar_line(pn, p, category, v, arch, f):
                                 if category not in p.vermap[v]:
                                     return
-                                t = p.vermap[v][category]
                                 size = int(math.ceil(p.tar(v, category).size / 1024))
                                 name = v if category == 'install' else v + ' (source)'
                                 target = "%s-%s" % (p.orig_name, v) + ('' if category == 'install' else '-src')
diff --git a/calm/spelling.py b/calm/spelling.py
index d3d53f4..505c1fb 100644
--- a/calm/spelling.py
+++ b/calm/spelling.py
@@ -102,7 +102,7 @@ def spellcheck_hints(args, packages):
             w = re.sub(r'[\d.]*$', '', w)
 
             # both with and without any lib prefix
-            for w1 in [w, re.sub(r'^lib', '', w)]:
+            for wl in [w, re.sub(r'^lib', '', w)]:
                 # add the package name unless it exists in the list above, which
                 # will give a canonical capitalization
                 if wl.lower() not in wordlist:
diff --git a/calm/uploads.py b/calm/uploads.py
index 9914a16..747b0dc 100644
--- a/calm/uploads.py
+++ b/calm/uploads.py
@@ -30,7 +30,6 @@ import filecmp
 import os
 import logging
 import re
-import shutil
 import tarfile
 import time
 
diff --git a/pep8 b/pep8
index 6230d52..6028029 100755
--- a/pep8
+++ b/pep8
@@ -1,3 +1,3 @@
 #!/bin/sh
 set -e
-grep -s -l '^#!/usr/bin/env python' * calm/* test/* | xargs python3 -m pycodestyle --count --show-source --max-line-length=240 --ignore=E129,E741,W504
+grep -s -l '^#!/usr/bin/env python' * calm/* test/* | xargs flake8 --count --show-source --max-line-length=240 --ignore=E129,E741,W504
diff --git a/test/mail-test b/test/mail-test
new file mode 100755
index 0000000..383f66e
--- /dev/null
+++ b/test/mail-test
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+
+import logging
+import os
+import time
+
+from calm.calm import mail_logs
+
+toaddrs = [os.environ.get('EMAIL', 'debug')]
+
+with mail_logs(True, toaddrs=toaddrs, subject='buffering_smtp_handler test (unicode)', thresholdLevel=logging.WARNING) as email:
+    logging.warning("this is a test")
+    logging.warning("unicode content: à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ù ú û ü")
+    logging.info("this should not appear in the sent mail")
+    logging.error("too many €")
+
+time.sleep(10)
+
+with mail_logs(True, toaddrs=toaddrs, subject='buffering_smtp_handler test (ascii)', thresholdLevel=logging.WARNING) as email:
+    logging.warning("this is a test")
+    logging.info("this should not appear in the sent mail")
+    logging.warning("no unicode content, should be ascii encoded")



More information about the Cygwin-apps-cvs mailing list