[Mailman-Users] Renaming a list

Chris Nulk cnulk at scu.edu
Tue Mar 29 14:51:38 EDT 2016


On 3/24/2016 11:49 AM, Mark Sapiro wrote:
> On 03/24/2016 09:17 AM, Chris Nulk wrote:
>> I did a little searching around our lists.  It seems the attachments
>> directory is always created and populated whether or not scrub_nondigest
>> was ever set to Yes.  So I can't really use the existence of the
>> attachments directory or the lack of it being populated as a check for
>> if scrub_nondigest was ever set to Yes.
>
> No, but here's what you can look for.
>
> If scrub_nondigest is True, the message will be scrubbed during
> processing before any delivery and before the message is added to the
> cumulative mbox. Thus there will be one copy of each scrubbed attachment
> in the attachments directory and a link in the message body and the
> scrubbed attachment will not be in the cumulative mbox.
>

[SNIPPED a big chunk]

> The loss of data problem is if scrub_nondigest is No and was Yes in the
> past, the attachments that were scrubbed when it was Yes will be lost.
>
Thanks for the information Mark.  It is a messy situation.  I decided to 
simplify the changes I made to clone_list.

1. The -b/--rebuild_archives option now requires a Yes/No/? answer 
(don't know if I did it right in the parser)
2. If -b/--rebuild_archives is:
     a. specified on the command line but without Yes/No/?, '?' is assumed,
     b. '?', program prints warning message and exits,
     c. 'No', program proceeds with list cloning and does NOT rebuild 
the archives,
     d. 'Yes', program proceeds with list cloning and DOES rebuild the 
archives (no warnings).

Hopefully, the changes will catch casual mistakes.

Below is the diff from Mark's original clone_list.  Please let me know 
if there are any improvements to be made.

Thanks,
Chris

------------------- diff file ------------------------
--- clone_list    2016-03-18 10:28:14.000000000 -0700
+++ clone_list_scu    2016-03-29 11:23:22.000000000 -0700
@@ -109,6 +109,17 @@
                        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', nargs='?',
+                      const='?', default='No',
+                      help="""\
+Rebuild the archives of the new list. Requires -a/--archives.
+                      ***** WARNING *****
+If scrub_nondigest was 'Yes' at any time in a list's past,
+rebuilding the archives will lose the scrubbed attachments from the
+'Yes' period.  Please review the settings and archives for the list
+prior to rebuilding the archives.  At a minimum, make backups of the
+list and its archives.""")
      parser.add_argument('-e', '--extra_files',
                        dest='extra', action='store_true',
                        help="""\
@@ -186,6 +197,25 @@
              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.lower() not in set(['no', 'n', 'yes', 'y', 
'?']):
+        abort('%s is not valid for -b/--rebuild_archives.  Please 
answer Yes or No.' % ns.rebuild_archives)
+    rebuild_archives = ns.rebuild_archives[0].lower()
+    if rebuild_archives == '?':
+        abort("""
+Specifying rebuild_archives requires an affirmative indication for
+%s's archives to be rebuilt.
+
+                       ***** WARNING *****
+If scrub_nondigest was 'Yes' at any time in %s's past,
+rebuilding the archives will lose the scrubbed attachments from the
+'Yes' period.  Please review the settings and archives for %s
+prior to rebuilding the archives.  At a minimum, make backups of the
+list and its archives.""" % (old_list, old_list, old_list))
+
+    if rebuild_archives == 'y' 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 +298,26 @@
                     (ns.old_list, ns.new_list))
          copy_archives(old_list, new_list)

+    if rebuild_archives == 'y':
+        if ns.verbose:
+            print 'Rebuilding %s archives...' % ns.new_list
+        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()



More information about the Mailman-Users mailing list