~launchpad-pqm/launchpad/devel

3944.1.1 by Francis J. Lacoste
Use system version python2.4 for scripts.
1
#!/usr/bin/python2.4
3691.93.1 by Christian Reis
Factor the death row processing into a separate script. Implement the DeathRow processor, with size calculation, some optimizations and properly restricting it to a specific distribution, and a process-death-row script, which has a dry run mode. Do minor cleanups in DAR.publish(), implementing a DR.isUnstable() method. Test DeathRow. Change DiskPool file removal code to return the filesize of the file removed. Implement Source/BinaryPackageFilePublishing.displayname, with tests. Clean up publish-distro as much as I can..
2
"""Death row kickoff script."""
3
4
import _pythonpath
5
6
from optparse import OptionParser
7
4785.4.2 by Celso Providelo
Fix #128126 (extend process-deathrow to support PPA removals. '--ppa' mode).
8
from zope.component import getUtility
9
10
from canonical.launchpad.interfaces import IDistributionSet
4687.5.18 by Celso Providelo
more review comments, r=salgado.
11
from canonical.config import config
4785.4.2 by Celso Providelo
Fix #128126 (extend process-deathrow to support PPA removals. '--ppa' mode).
12
from canonical.launchpad.scripts import (
13
    execute_zcml_for_scripts, logger, logger_options)
3691.93.1 by Christian Reis
Factor the death row processing into a separate script. Implement the DeathRow processor, with size calculation, some optimizations and properly restricting it to a specific distribution, and a process-death-row script, which has a dry run mode. Do minor cleanups in DAR.publish(), implementing a DR.isUnstable() method. Test DeathRow. Change DiskPool file removal code to return the filesize of the file removed. Implement Source/BinaryPackageFilePublishing.displayname, with tests. Clean up publish-distro as much as I can..
14
from canonical.lp import initZopeless
3691.93.15 by Christian Reis
Fix for bug #54345: archivepublisher module imports monolithically
15
4376.2.73 by Julian Edwards
Apply review comments.
16
from canonical.archivepublisher.deathrow import getDeathRow
3691.93.1 by Christian Reis
Factor the death row processing into a separate script. Implement the DeathRow processor, with size calculation, some optimizations and properly restricting it to a specific distribution, and a process-death-row script, which has a dry run mode. Do minor cleanups in DAR.publish(), implementing a DR.isUnstable() method. Test DeathRow. Change DiskPool file removal code to return the filesize of the file removed. Implement Source/BinaryPackageFilePublishing.displayname, with tests. Clean up publish-distro as much as I can..
17
3691.93.15 by Christian Reis
Fix for bug #54345: archivepublisher module imports monolithically
18
3691.93.1 by Christian Reis
Factor the death row processing into a separate script. Implement the DeathRow processor, with size calculation, some optimizations and properly restricting it to a specific distribution, and a process-death-row script, which has a dry run mode. Do minor cleanups in DAR.publish(), implementing a DR.isUnstable() method. Test DeathRow. Change DiskPool file removal code to return the filesize of the file removed. Implement Source/BinaryPackageFilePublishing.displayname, with tests. Clean up publish-distro as much as I can..
19
def main():
20
    parser = OptionParser()
21
    parser.add_option("-n", "--dry-run", action="store_true",
22
                      dest="dry_run", metavar="", default=False,
23
                      help=("Dry run: goes through the motions but "
24
                            "commits to nothing."))
25
    parser.add_option("-d", "--distribution",
26
                      dest="distribution", metavar="DISTRO",
27
                      help="Specified the distribution name.")
3691.176.2 by Malcolm Cleaton
Test for process-death-row script.
28
    parser.add_option("-p", "--pool-root", metavar="PATH",
29
                      help="Override the path to the pool folder")
4785.4.2 by Celso Providelo
Fix #128126 (extend process-deathrow to support PPA removals. '--ppa' mode).
30
    parser.add_option("--ppa", action="store_true",
31
                      dest="ppa", metavar="PPA", default=False,
32
                      help="Run only over PPA archives.")
3691.93.1 by Christian Reis
Factor the death row processing into a separate script. Implement the DeathRow processor, with size calculation, some optimizations and properly restricting it to a specific distribution, and a process-death-row script, which has a dry run mode. Do minor cleanups in DAR.publish(), implementing a DR.isUnstable() method. Test DeathRow. Change DiskPool file removal code to return the filesize of the file removed. Implement Source/BinaryPackageFilePublishing.displayname, with tests. Clean up publish-distro as much as I can..
33
34
    logger_options(parser)
35
    (options, args) = parser.parse_args()
36
    log = logger(options, "deathrow-distro")
37
38
    log.debug("Initialising zopeless.")
4785.4.2 by Celso Providelo
Fix #128126 (extend process-deathrow to support PPA removals. '--ppa' mode).
39
4687.5.18 by Celso Providelo
more review comments, r=salgado.
40
    txn = initZopeless(dbuser=config.archivepublisher.dbuser)
3691.93.1 by Christian Reis
Factor the death row processing into a separate script. Implement the DeathRow processor, with size calculation, some optimizations and properly restricting it to a specific distribution, and a process-death-row script, which has a dry run mode. Do minor cleanups in DAR.publish(), implementing a DR.isUnstable() method. Test DeathRow. Change DiskPool file removal code to return the filesize of the file removed. Implement Source/BinaryPackageFilePublishing.displayname, with tests. Clean up publish-distro as much as I can..
41
    execute_zcml_for_scripts()
42
4785.4.2 by Celso Providelo
Fix #128126 (extend process-deathrow to support PPA removals. '--ppa' mode).
43
    distribution = getUtility(IDistributionSet).getByName(
44
        options.distribution)
45
46
    if not options.ppa:
47
        archives = distribution.all_distro_archives
48
    else:
49
        archives = distribution.getAllPPAs()
50
51
    for archive in archives:
4785.4.5 by Celso Providelo
applying review comments, [r=kiko].
52
        death_row = getDeathRow(archive, log, options.pool_root)
4376.2.26 by Julian Edwards
Make deathrow processing archive-aware. It will now loop through
53
        try:
54
            # Unpublish death row
4785.4.2 by Celso Providelo
Fix #128126 (extend process-deathrow to support PPA removals. '--ppa' mode).
55
            log.debug("Unpublishing death row for %s." % archive.title)
4376.2.26 by Julian Edwards
Make deathrow processing archive-aware. It will now loop through
56
            death_row.reap(options.dry_run)
57
58
            if options.dry_run:
59
                log.debug("Dry run mode; rolling back.")
60
                txn.abort()
61
            else:
62
                log.debug("Committing")
63
                txn.commit()
64
        except:
4376.2.73 by Julian Edwards
Apply review comments.
65
            log.exception("Unexpected exception while doing death-row "
66
                          "unpublish")
3691.176.1 by Malcolm Cleaton
Fix bug 65589 (dryrun vs. commit backwards in death row)
67
            txn.abort()
4376.2.73 by Julian Edwards
Apply review comments.
68
            # Continue with other archives.
3691.93.1 by Christian Reis
Factor the death row processing into a separate script. Implement the DeathRow processor, with size calculation, some optimizations and properly restricting it to a specific distribution, and a process-death-row script, which has a dry run mode. Do minor cleanups in DAR.publish(), implementing a DR.isUnstable() method. Test DeathRow. Change DiskPool file removal code to return the filesize of the file removed. Implement Source/BinaryPackageFilePublishing.displayname, with tests. Clean up publish-distro as much as I can..
69
3691.93.15 by Christian Reis
Fix for bug #54345: archivepublisher module imports monolithically
70
3691.93.1 by Christian Reis
Factor the death row processing into a separate script. Implement the DeathRow processor, with size calculation, some optimizations and properly restricting it to a specific distribution, and a process-death-row script, which has a dry run mode. Do minor cleanups in DAR.publish(), implementing a DR.isUnstable() method. Test DeathRow. Change DiskPool file removal code to return the filesize of the file removed. Implement Source/BinaryPackageFilePublishing.displayname, with tests. Clean up publish-distro as much as I can..
71
if __name__ == "__main__":
72
    main()
73