[sysadmin-bin] Create a file only if we have anything to actually write



commit 24f0307b02eda3607583fa1b0121b8a9727a8633
Author: Andrea Veri <averi redhat com>
Date:   Fri Feb 25 13:50:21 2022 +0100

    Create a file only if we have anything to actually write

 membership/foundation-operations.py | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/membership/foundation-operations.py b/membership/foundation-operations.py
index f8ce176..4074352 100755
--- a/membership/foundation-operations.py
+++ b/membership/foundation-operations.py
@@ -198,17 +198,15 @@ def subscribe_new_members():
         else:
             pass
 
-    for i in new_members:
-        with open('/tmp/new_subscribers', 'w') as fl:
-            fl.write(f'{ ldap_vars[0] }@gnome.org' + '\n')
-
-    if os.path.getsize('/tmp/new_subscribers') == 0:
-        os.remove('/tmp/new_subscribers')
-    else:
-        import subprocess
-        subscribe = subprocess.Popen(['/usr/lib/mailman/bin/add_members', '-a', 'n', '-r', 
'/tmp/new_subscribers', 'foundation-announce'])
-        subscribe.wait()
-        os.remove('/tmp/new_subscribers')
+    if len(new_members) > 0:
+        for i in new_members:
+            with open('/tmp/new_subscribers', 'w') as fl:
+                fl.write(f'{ ldap_vars[0] }@gnome.org' + '\n')
+
+            import subprocess
+            subscribe = subprocess.Popen(['/usr/lib/mailman/bin/add_members', '-a', 'n', '-r', 
'/tmp/new_subscribers', 'foundation-announce'])
+            subscribe.wait()
+            os.remove('/tmp/new_subscribers')
 
 
 new_member_form_letter = string.Template("""


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]