public inbox for [email protected]  
help / color / mirror / Atom feed
From: Célestin Matte <[email protected]>
To: [email protected]
Subject: [PATCH] pglister: load_subscribers.py: don't wait for user input when there is nothing to commit
Date: Wed, 3 Nov 2021 20:01:37 +0100
Message-ID: <[email protected]> (raw)


-- 
Célestin Matte

Attachments:

  [text/x-patch] 0001-load_subscribers.py-don-t-wait-for-user-input-when-t.patch (1.4K, 2-0001-load_subscribers.py-don-t-wait-for-user-input-when-t.patch)
  download | inline diff:
From 05e778e77f3a33b66626bf3668eca4c899c22a0b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <[email protected]>
Date: Wed, 3 Nov 2021 10:56:41 +0100
Subject: [PATCH] load_subscribers.py: don't wait for user input when there is
 nothing to commit

---
 bin/load_subscribers.py | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/bin/load_subscribers.py b/bin/load_subscribers.py
index 2b894bf..62e2be1 100755
--- a/bin/load_subscribers.py
+++ b/bin/load_subscribers.py
@@ -104,15 +104,18 @@ if __name__ == "__main__":
         })
         newsub += curs.rowcount
 
-    while True:
-        r = input('Added %s subscribers, of which %s were new. Commit? ' % (newsub, newaddr)).strip().lower()
-        if r == 'y':
-            break
-        elif r == 'n':
-            print("OK, aborting")
-            conn.rollback()
-            sys.exit(1)
-    print("OK, committing")
-    conn.commit()
+    if newaddr > 0:
+        while True:
+            r = input('Added %s subscribers, of which %s were new. Commit? ' % (newsub, newaddr)).strip().lower()
+            if r == 'y':
+                break
+            elif r == 'n':
+                print("OK, aborting")
+                conn.rollback()
+                sys.exit(1)
+        print("OK, committing")
+        conn.commit()
+    else:
+        print("No new subscriber, nothing to do.")
     print("Done.")
     conn.close()
-- 
2.33.1



view thread (2+ messages)  latest in thread

reply

Reply instructions:

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

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: [PATCH] pglister: load_subscribers.py: don't wait for user input when there is nothing to commit
  In-Reply-To: <[email protected]>

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

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox