Hello all,

We have come up a few times where a list was created incorrectly. Normally, we catch the mistake, delete the list, and recreate it properly. However, there are times when the mistake is caught after having been in use. So, the delete and recreate is not available to use.

I have a copy of Mark's clone_list command and it will allow us to rename lists. Which is great and not a problem for me. However, I am not the person normally involved with list creation, etc. Another group does it. Normally through the web interface which works well for them. Unless a mistake is made then they have to use the command line tools. Again, not a problem for me but that group has very limited knowledge of linux/unix and Mailman.

I can easily train them to use the Mailman tools, however, ensuring they do the appropriate checks to avoid other problems is more difficult. Specifically, they can run the clone_list command but rebuilding the archives requires checking if the scrub_nondigest settings is No (this is explained in the clone_list help).

What I have done is modify the clone_list command to combine the renaming/cloning of a list and include an option to rebuild the archives. However, the archives will not be rebuilt if the scrub_nondigest setting is Yes.

Below my message is a diff of my changes to clone_list. While I try testing my changes on a test system, I would appreciate it if someone could take a look at my changes to ensure I am not off-base with my process.

Thank you,
Chris

--------------- My diff of clone_list -----------
--- clone_list    2016-03-18 10:28:14.000000000 -0700
+++ clone_list_scu    2016-03-22 10:19:43.000000000 -0700
@@ -109,6 +109,10 @@
                       dest='archives', action='store_true',
                       help="""\
 Clone the archives of the old list. The default is an empty archive.""")
+    parser.add_argument('-b', '--rebuild_archives',
+                      dest='rebuild_archives', action='store_true',
+                      help="""\
+Rebuild the archives of the new list. Requires -a/--archives.""")
     parser.add_argument('-e', '--extra_files',
                       dest='extra', action='store_true',
                       help="""\
@@ -186,6 +190,8 @@
abort("%s doesn't appear to be a valid email address" % ns.owner)
     if ns.extra and not ns.clone_members:
         abort('-e/--extra_files requires -m/--members.')
+    if ns.rebuild_archives and not ns.archives:
+        abort('-b/--rebuild_archives requires -a/--archives.')
     if ns.verbose:
         print 'Getting %s list...' % ns.old_list
     ol = MailList(old_list, lock=False)
@@ -268,5 +274,29 @@
                    (ns.old_list, ns.new_list))
         copy_archives(old_list, new_list)

+    if ns.rebuild_archives:
+        if ns.verbose:
+            print 'Rebuilding %s archives...' % ns.new_list
+        if ol.scrub_nondigest:
+ abort('Scrub_nondigest is YES for %s. WILL NOT REBUILD ARCHIVES.' % ns.old_list)
+        else:
+            archcmd = os.path.join(os.path.dirname(sys.argv[0]), 'arch')
+            if not os.path.isfile(archcmd):
+                abort("""%s doesn't exist.
+Am I installed in Mailman's bin/ directory?""" % archcmd)
+            rbld = subprocess.Popen([archcmd,
+                                     '--wipe',
+                                     new_list
+                                    ],
+                                    stdout=subprocess.PIPE,
+                                    stderr=subprocess.PIPE
+                                   )
+            so, se = rbld.communicate()
+            if rbld.returncode:
+ abort('unable to rebuild archives for %s\n%s' % (ns.new_list, se))
+            # If there was stdout output, print it. It is probably aliases.
+            if so:
+                print so
+
 if __name__ == '__main__':
     main()

------------------------------------------------------
Mailman-Users mailing list Mailman-Users@python.org
https://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Reply via email to