14
from optparse import OptionParser
17
15
from zope.component import getUtility
18
# Still needed fake import to stop circular imports.
19
import canonical.launchpad.interfaces
21
17
from canonical.config import config
22
from canonical.launchpad.scripts import (
23
execute_zcml_for_scripts, logger, logger_options)
24
18
from lp.app.errors import NotFoundError
25
from canonical.lp import initZopeless
26
19
from lp.registry.interfaces.distribution import IDistributionSet
27
20
from lp.registry.interfaces.pocket import PackagePublishingPocket
21
from lp.services.scripts.base import LaunchpadScript
28
22
from lp.soyuz.scripts.ftpmaster import PubSourceChecker
29
23
from lp.soyuz.enums import PackagePublishingStatus
31
from contrib.glock import GlobalLock
34
# Parse command-line arguments
35
parser = OptionParser()
36
logger_options(parser)
38
parser.add_option("-d", "--distribution", action="store",
39
dest="distribution", metavar="DISTRO", default="ubuntu",
40
help="Distribution to consider")
42
parser.add_option("-s", "--suite", action="store",
43
dest="suite", metavar="SUITE", default=None,
44
help=("Suite to consider, if not passed consider the "
45
"currentseries and the RELEASE pocket"))
47
(options, args) = parser.parse_args()
49
log = logger(options, "archive-override-check")
51
log.debug("Acquiring lock")
52
lock = GlobalLock('/var/lock/archive-override-check.lock')
53
lock.acquire(blocking=True)
55
log.debug("Initializing connection.")
56
execute_zcml_for_scripts()
57
ztm = initZopeless(dbuser=config.archivepublisher.dbuser)
26
class ArchiveOverrideCheckScript(LaunchpadScript):
28
def add_my_options(self):
29
self.parser.add_option(
30
"-d", "--distribution", action="store",
31
dest="distribution", metavar="DISTRO", default="ubuntu",
32
help="Distribution to consider")
33
self.parser.add_option(
34
"-s", "--suite", action="store",
35
dest="suite", metavar="SUITE", default=None,
36
help=("Suite to consider, if not passed consider the "
37
"currentseries and the RELEASE pocket"))
61
distribution = getUtility(IDistributionSet)[options.distribution]
62
if options.suite is None:
63
distroseries = distribution.currentseries
64
pocket = PackagePublishingPocket.RELEASE
66
distroseries, pocket = distribution.getDistroSeriesAndPocket(
69
log.debug("Considering: %s/%s/%s/%s."
70
% (distribution.name, distroseries.name, pocket.name,
71
distroseries.status.name))
73
checkOverrides(distroseries, pocket, log)
75
except NotFoundError, info:
76
log.error('Not found: %s' % info)
79
log.debug("Rolling back any remaining transactions.")
81
log.debug("Releasing lock")
42
distribution = getUtility(IDistributionSet)[
43
self.options.distribution]
44
if self.options.suite is None:
45
distroseries = distribution.currentseries
46
pocket = PackagePublishingPocket.RELEASE
48
distroseries, pocket = (
49
distribution.getDistroSeriesAndPocket(
53
"Considering: %s/%s/%s/%s."
54
% (distribution.name, distroseries.name, pocket.name,
55
distroseries.status.name))
57
checkOverrides(distroseries, pocket, self.logger)
58
except NotFoundError, info:
59
self.logger.error('Not found: %s' % info)
61
self.logger.debug("Rolling back any remaining transactions.")
87
65
def checkOverrides(distroseries, pocket, log):