~launchpad-pqm/mailman/2.1

« back to all changes in this revision

Viewing changes to bin/update

  • Committer: Launchpad Patch Queue Manager
  • Date: 2009-10-21 01:06:17 UTC
  • mfrom: (975.1.1 mailman.2112)
  • Revision ID: launchpad@pqm.canonical.com-20091021010617-prbs2ay6nhxx515v
[rs=flacoste] Upgrade Mailman to upstream 2.1.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! @PYTHON@
2
2
#
3
 
# Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
 
3
# Copyright (C) 1998-2008 by the Free Software Foundation, Inc.
4
4
#
5
5
# This program is free software; you can redistribute it and/or
6
6
# modify it under the terms of the GNU General Public License
34
34
"""
35
35
 
36
36
import os
37
 
import md5
38
37
import sys
39
38
import time
40
39
import errno
131
130
            # No global template
132
131
            continue
133
132
 
134
 
        gcksum = md5.new(fp.read()).digest()
 
133
        gcksum = Utils.md5_new(fp.read()).digest()
135
134
        fp.close()
136
135
        # Match against the lists/<list>/* template
137
136
        try:
139
138
        except IOError, e:
140
139
            if e.errno <> errno.ENOENT: raise
141
140
        else:
142
 
            tcksum = md5.new(fp.read()).digest()
 
141
            tcksum = Utils.md5_new(fp.read()).digest()
143
142
            fp.close()
144
143
            if gcksum == tcksum:
145
144
                os.unlink(os.path.join(mlist.fullpath(), gtemplate))
149
148
        except IOError, e:
150
149
            if e.errno <> errno.ENOENT: raise
151
150
        else:
152
 
            tcksum = md5.new(fp.read()).digest()
 
151
            tcksum = Utils.md5_new(fp.read()).digest()
153
152
            fp.close()
154
153
            if gcksum == tcksum:
155
154
                os.unlink(os.path.join(mlist.fullpath(), gtemplate + '.prev'))
159
158
        except IOError, e:
160
159
            if e.errno <> errno.ENOENT: raise
161
160
        else:
162
 
            tcksum = md5.new(fp.read()).digest()
 
161
            tcksum = Utils.md5_new(fp.read()).digest()
163
162
            fp.close()
164
163
            if gcksum == tcksum:
165
164
                os.unlink(os.path.join(mlist.fullpath(), 'en', gtemplate))
169
168
        except IOError, e:
170
169
            if e.errno <> errno.ENOENT: raise
171
170
        else:
172
 
            tcksum = md5.new(fp.read()).digest()
 
171
            tcksum = Utils.md5_new(fp.read()).digest()
173
172
            fp.close()
174
173
            if gcksum == tcksum:
175
174
                os.unlink(os.path.join(mm_cfg.TEMPLATE_DIR, gtemplate))
179
178
        except IOError, e:
180
179
            if e.errno <> errno.ENOENT: raise
181
180
        else:
182
 
            tcksum = md5.new(fp.read()).digest()
 
181
            tcksum = Utils.md5_new(fp.read()).digest()
183
182
            fp.close()
184
183
            if gcksum == tcksum:
185
184
                os.unlink(os.path.join(mm_cfg.TEMPLATE_DIR,
342
341
    # and move them to the new place if there's not already
343
342
    # a new one there
344
343
    #
345
 
    tmpl_dir = os.path.join(mm_cfg.PREFIX, "templates")
346
 
    list_dir = os.path.join(mm_cfg.PREFIX, "lists")
347
 
    b4_tmpl_dir = os.path.join(tmpl_dir, mlist._internal_name)
348
 
    new_tmpl_dir = os.path.join(list_dir, mlist._internal_name)
349
 
    if os.path.exists(b4_tmpl_dir):
350
 
        print _("""\
 
344
    # There is a problem with the following if the list name is equal
 
345
    # to a language code. All the templates get moved from templates/xx
 
346
    # to lists/xx. To avoid this, test the list name, and if it is 'en'
 
347
    # or matches a name in the messages directory, just skip this step.
 
348
    if (mlist._internal_name <> 'en' and
 
349
        mlist._internal_name not in os.listdir(mm_cfg.MESSAGES_DIR)):
 
350
        # It's okay to move the templates.
 
351
        tmpl_dir = os.path.join(mm_cfg.PREFIX, "templates")
 
352
        list_dir = mm_cfg.LIST_DATA_DIR
 
353
        b4_tmpl_dir = os.path.join(tmpl_dir, mlist._internal_name)
 
354
        new_tmpl_dir = os.path.join(list_dir, mlist._internal_name)
 
355
        if os.path.exists(b4_tmpl_dir):
 
356
            print _("""\
351
357
- This list looks like it might have <= b4 list templates around""")
352
 
        for f in os.listdir(b4_tmpl_dir):
353
 
            o_tmpl = os.path.join(b4_tmpl_dir, f)
354
 
            n_tmpl = os.path.join(new_tmpl_dir, f)
355
 
            if os.path.exists(o_tmpl):
356
 
                if not os.path.exists(n_tmpl):
357
 
                    os.rename(o_tmpl, n_tmpl)
358
 
                    print _('- moved %(o_tmpl)s to %(n_tmpl)s')
 
358
            for f in os.listdir(b4_tmpl_dir):
 
359
                o_tmpl = os.path.join(b4_tmpl_dir, f)
 
360
                n_tmpl = os.path.join(new_tmpl_dir, f)
 
361
                if os.path.exists(o_tmpl):
 
362
                    if not os.path.exists(n_tmpl):
 
363
                        os.rename(o_tmpl, n_tmpl)
 
364
                        print _('- moved %(o_tmpl)s to %(n_tmpl)s')
 
365
                    else:
 
366
                        print _("""\
 
367
- both %(o_tmpl)s and %(n_tmpl)s exist, leaving untouched""")
359
368
                else:
360
369
                    print _("""\
361
 
- both %(o_tmpl)s and %(n_tmpl)s exist, leaving untouched""")
362
 
            else:
363
 
                print _("""\
364
370
- %(o_tmpl)s doesn't exist, leaving untouched""")
365
371
    #
366
372
    # Move all the templates to the en language subdirectory as required for
435
441
            for filename in os.listdir(dirpath):
436
442
                filepath = os.path.join(dirpath, filename)
437
443
                filebase, ext = os.path.splitext(filepath)
 
444
                # A bug in Mailman 2.1.9 left .bak files behind in some
 
445
                # circumstances. It should be safe to remove them.
 
446
                if ext == '.bak':
 
447
                    os.remove(filepath)
438
448
                # Handle the .db metadata files as part of the handling of the
439
449
                # .pck or .msg message files.
440
450
                if ext not in ('.pck', '.msg'):