public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
From: jturney@sourceware.org
To: cygwin-apps-cvs@sourceware.org
Subject: [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20160705-15-g2e76b35
Date: Wed, 07 Sep 2016 13:28:00 -0000	[thread overview]
Message-ID: <20160907132839.79402.qmail@sourceware.org> (raw)




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

commit 2e76b3557432f1a3283ec9ad8ac9330be0cf6caf
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Wed Sep 7 14:25:06 2016 +0100

    Move best_version identifcation after check that there are some versions
    
    Selection of the best version should take place after assuring there are
    some versions, in case there are none.

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

commit fefa2aa0ef2a223327b75b4aab280a3df7a661d0
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Wed Aug 31 18:19:36 2016 +0100

    Fix a bit of logging

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

commit 2674ffdbbf22526b0d846bddd36c0d3a5a527f7f
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Aug 30 12:41:21 2016 +0100

    Add module for sending mesages to IRC via irked


Diff:
---
 calm/calm.py    |    2 +-
 calm/irk.py     |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 calm/package.py |   14 +++++++-------
 3 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/calm/calm.py b/calm/calm.py
index 7c7ff4d..3f7f374 100755
--- a/calm/calm.py
+++ b/calm/calm.py
@@ -92,7 +92,7 @@ def process(args):
 
             # validate the package set
             if not package.validate_packages(args, packages[arch]):
-                logging.error("existing %s package set has errors", arch)
+                logging.error("existing %s package set has errors" % (arch))
                 error = True
 
         if error:
diff --git a/calm/irk.py b/calm/irk.py
new file mode 100755
index 0000000..b9f8957
--- /dev/null
+++ b/calm/irk.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python3
+#
+# Tell irked to send a message to an IRC channel
+#
+# First argument must be a channel URL. If it does not begin with "irc",
+# the base URL for freenode is prepended.
+#
+# SPDX-License-Identifier: BSD-2-Clause
+
+import json
+import socket
+import sys
+
+DEFAULT_SERVER = ("localhost", 6659)
+DEFAULT_TARGET = 'cygwin-bots'
+
+
+def connect(server=DEFAULT_SERVER):
+    return socket.create_connection(server)
+
+
+def send(s, target, message):
+    data = {"to": target, "privmsg": message}
+    # print(json.dumps(data))
+    s.sendall(bytes(json.dumps(data), "ascii"))
+
+
+def irk(message, target=DEFAULT_TARGET, server=DEFAULT_SERVER):
+    s = connect(server)
+    if "irc:" not in target and "ircs:" not in target:
+        target = "irc://chat.freenode.net/{0}".format(target)
+
+    send(s, target, message)
+
+    s.close()
+
+
+def main():
+    message = " ".join(sys.argv[:])
+
+    try:
+        irk(message)
+    except socket.error as e:
+        sys.stderr.write("irk: write to server failed: %r\n" % e)
+        sys.exit(1)
+
+if __name__ == '__main__':
+    main()
diff --git a/calm/package.py b/calm/package.py
index 6dbceb4..e198c9e 100755
--- a/calm/package.py
+++ b/calm/package.py
@@ -483,13 +483,6 @@ def validate_packages(args, packages):
             if l in packages[p].override_hints:
                 packages[p].stability[l] = packages[p].override_hints[l]
 
-        # identify a 'best' version to take certain information from: this is
-        # the curr version, if we have one, otherwise, the highest version.
-        if 'curr' in packages[p].stability:
-            packages[p].best_version = packages[p].stability['curr']
-        else:
-            packages[p].best_version = sorted(packages[p].vermap.keys(), key=lambda v: SetupVersion(v), reverse=True)[0]
-
         # the package must have some versions
         if not packages[p].stability:
             logging.error("package '%s' doesn't have any versions" % (p))
@@ -498,6 +491,13 @@ def validate_packages(args, packages):
         elif 'curr' not in packages[p].stability and 'curr' not in getattr(args, 'okmissing', []):
             logging.warning("package '%s' doesn't have a curr version" % (p))
 
+        # identify a 'best' version to take certain information from: this is
+        # the curr version, if we have one, otherwise, the highest version.
+        if 'curr' in packages[p].stability:
+            packages[p].best_version = packages[p].stability['curr']
+        else:
+            packages[p].best_version = sorted(packages[p].vermap.keys(), key=lambda v: SetupVersion(v), reverse=True)[0]
+
         # If, for every stability level, the install tarball is empty and there
         # is no source tarball, we should probably be marked obsolete
         if not packages[p].skip:


                 reply	other threads:[~2016-09-07 13:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160907132839.79402.qmail@sourceware.org \
    --to=jturney@sourceware.org \
    --cc=cygwin-apps-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).