~launchpad-pqm/launchpad/devel

3944.1.1 by Francis J. Lacoste
Use system version python2.4 for scripts.
1
#!/usr/bin/python2.4
8687.15.22 by Karl Fogel
Add the copyright header block to the remaining .py files.
2
#
3
# Copyright 2009 Canonical Ltd.  This software is licensed under the
4
# GNU Affero General Public License version 3 (see the file LICENSE).
5
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
6
# This module uses relative imports.
5855.5.1 by Curtis Hovey
Migrate db configuration to lazr.config.
7
# pylint: disable-msg=W0403
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
8
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
9
"""
10
Gina launcher script. Handles commandline options and makes the proper
11
calls to the other classes and instances.
12
13
The callstack is essentially:
14
    main -> run_gina 
15
                -> import_sourcepackages -> do_one_sourcepackage
16
                -> import_binarypackages -> do_one_binarypackage
17
"""
18
5855.5.1 by Curtis Hovey
Migrate db configuration to lazr.config.
19
20
__metaclass__ = type
21
22
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
23
# Set to non-zero if you'd like to be warned every so often
24
COUNTDOWN = 0
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
25
26
import _pythonpath
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
27
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
28
from optparse import OptionParser
2670 by Canonical.com Patch Queue Manager
[trivial] Gina love
29
import os
5821.10.4 by Celso Providelo
fixing gina tests.
30
import psycopg2
2670 by Canonical.com Patch Queue Manager
[trivial] Gina love
31
import sys
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
32
import time
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
33
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
34
from zope.component import getUtility
35
3691.348.2 by kiko
Only catch LockAlreadyAcquired, which is really what we are checking for in scripts.
36
from contrib.glock import GlobalLock, LockAlreadyAcquired
3691.348.1 by kiko
Remove the original lockfile class and use our contributed GlobalLock everywhere to avoid stale locks making our scripts stop to run. Update a bunch of scripts to use it. Hopefully backwards-compatible enough to survive tests.
37
6555.7.35 by Stuart Bishop
Fix gina tests
38
from canonical import lp
5028.1.6 by David Murphy
Removed PackagePublishingPriority, PackagePublishingStatus, PackagePublishingPocket, PackageUploadStatus, & PackageUploadCustomFormat from canonical.lp.dbschema.
39
from canonical.lp import initZopeless
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
40
from canonical.config import config
8294.6.8 by Julian Edwards
Section and component are now moved, and gina imports fixed.
41
from lp.soyuz.interfaces.component import IComponentSet
3691.164.16 by Guilherme Salgado
Lots of fixes and tests suggested by Bjorn
42
from canonical.launchpad.scripts import (
43
    execute_zcml_for_scripts, logger_options, log)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
44
8294.6.8 by Julian Edwards
Section and component are now moved, and gina imports fixed.
45
from lp.soyuz.scripts.gina import ExecutionError
46
from lp.soyuz.scripts.gina.katie import Katie
47
from lp.soyuz.scripts.gina.archive import (ArchiveComponentItems,
1716.1.223 by Christian Reis
Checkpoint gina: the sourcepackage side is implemented and well-tested, over two releases, and over two runs of gina
48
    PackagesMap, MangledArchiveError)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
49
8294.6.8 by Julian Edwards
Section and component are now moved, and gina imports fixed.
50
from lp.soyuz.scripts.gina.handlers import (ImporterHandler,
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
51
    MultiplePackageReleaseError, NoSourcePackageError, DataSetupError)
8294.6.8 by Julian Edwards
Section and component are now moved, and gina imports fixed.
52
from lp.soyuz.scripts.gina.packages import (SourcePackageData,
1716.1.229 by Christian Reis
Move encoding of person's displayname into packages. Add tests for version numbers for gcc-defaults, clean up code slightly. What remains: validating ensureBuild and _getBinary, and testing with multiple components, pockets and architectures
53
    BinaryPackageData, MissingRequiredArguments, DisplayNameDecodingError,
1716.1.239 by Christian Reis
Really fix get_dsc_path to properly grok archive paths (and sanitize callsites and a certain place where we were generating a filename without the string pool attached to it). Remove PackageFileProcessError, which was dead anyway, and update for it. Rename anything that was an archive_root to the right term. All tests now pass
54
    PoolFileNotFound, InvalidVersionError)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
55
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
56
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
57
def _get_keyring(keyrings_root):
4664.1.1 by Curtis Hovey
Normalized comments for bug 3732.
58
    # XXX kiko 2005-10-23: untested
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
59
    keyrings = ""
60
    for keyring in os.listdir(keyrings_root):
61
        path = os.path.join(keyrings_root, keyring)
62
        keyrings += " --keyring=%s" % path
63
    if not keyrings:
64
        raise AttributeError("Keyrings not found in ./keyrings/")
65
    return keyrings
66
67
68
def main():
3691.164.16 by Guilherme Salgado
Lots of fixes and tests suggested by Bjorn
69
    execute_zcml_for_scripts()
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
70
    parser = OptionParser("Usage: %prog [OPTIONS] [target ...]")
71
    logger_options(parser)
72
73
    parser.add_option("-n", "--dry-run", action="store_true",
74
            help="Don't commit changes to the database",
75
            dest="dry_run", default=False)
76
77
    parser.add_option("-a", "--all", action="store_true",
78
            help="Run all sections defined in launchpad.conf (in order)",
79
            dest="all", default=False)
80
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
81
    parser.add_option( "-l", "--lockfile",
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
82
            default="/var/lock/launchpad-gina.lock",
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
83
            help="Ensure only one process is running that locks LOCKFILE",
84
            metavar="LOCKFILE"
85
            )
86
87
    (options, targets) = parser.parse_args()
88
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
89
    possible_targets = [target.category_and_section_names[1]
90
                        for target in config.getByCategory('gina_target')]
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
91
92
    if options.all:
93
        targets = possible_targets[:]
94
    else:
95
        if not targets:
96
            parser.error("Must specify at least one target to run, or --all")
97
98
        for target in targets:
99
            if target not in possible_targets:
100
                parser.error("No Gina target %s in config file" % target)
101
3691.348.1 by kiko
Remove the original lockfile class and use our contributed GlobalLock everywhere to avoid stale locks making our scripts stop to run. Update a bunch of scripts to use it. Hopefully backwards-compatible enough to survive tests.
102
    lockfile = GlobalLock(options.lockfile, logger=log)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
103
    try:
104
        lockfile.acquire()
3691.348.2 by kiko
Only catch LockAlreadyAcquired, which is really what we are checking for in scripts.
105
    except LockAlreadyAcquired:
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
106
        log.info('Lockfile %s already locked. Exiting.', options.lockfile)
107
        sys.exit(1)
108
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
109
    ztm = initZopeless(dbuser=config.gina.dbuser)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
110
    try:
111
        for target in targets:
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
112
            target_section = config['gina_target.%s' % target]
113
            run_gina(options, ztm, target_section)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
114
    finally:
115
        lockfile.release()
116
117
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
118
def run_gina(options, ztm, target_section):
8294.6.8 by Julian Edwards
Section and component are now moved, and gina imports fixed.
119
    # Avoid circular imports.
120
    from lp.soyuz.interfaces.publishing import PackagePublishingPocket
121
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
122
    package_root = target_section.root
123
    keyrings_root = target_section.keyrings
124
    distro = target_section.distro
5121.2.7 by Stuart Bishop
More required code changes
125
    # XXX kiko 2005-10-23: I honestly think having a separate distroseries
126
    # bit silly. Can't we construct this based on `distroseries-pocket`?
127
    pocket_distroseries = target_section.pocketrelease
128
    distroseries = target_section.distroseries
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
129
    components = [c.strip() for c in target_section.components.split(",")]
130
    archs = [a.strip() for a in target_section.architectures.split(",")]
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
131
    pocket = target_section.pocket
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
132
    component_override = target_section.componentoverride
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
133
    source_only = target_section.source_only
134
    spnames_only = target_section.sourcepackagenames_only
135
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
136
    dry_run = options.dry_run
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
137
6555.7.35 by Stuart Bishop
Fix gina tests
138
    LPDB = lp.dbname
139
    LPDB_HOST = lp.dbhost
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
140
    LPDB_USER = config.gina.dbuser
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
141
    KTDB = target_section.katie_dbname
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
142
143
    LIBRHOST = config.librarian.upload_host
144
    LIBRPORT = config.librarian.upload_port
1716.1.211 by Christian Reis
De-lintify and add better exceptions to gina.py
145
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
146
    log.info("")
5121.2.7 by Stuart Bishop
More required code changes
147
    log.info("=== Processing %s/%s/%s ===" % (distro, distroseries, pocket))
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
148
    log.debug("Packages read from: %s" % package_root)
149
    log.debug("Keyrings read from: %s" % keyrings_root)
150
    log.info("Components to import: %s" % ", ".join(components))
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
151
    if component_override is not None:
152
        log.info("Override components to: %s" % component_override)
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
153
    log.info("Architectures to import: %s" % ", ".join(archs))
154
    log.debug("Launchpad database: %s" % LPDB)
155
    log.debug("Launchpad database host: %s" % LPDB_HOST)
156
    log.debug("Launchpad database user: %s" % LPDB_USER)
157
    log.info("Katie database: %s" % KTDB)
1716.1.211 by Christian Reis
De-lintify and add better exceptions to gina.py
158
    log.info("SourcePackage Only: %s" % source_only)
159
    log.info("SourcePackageName Only: %s" % spnames_only)
160
    log.debug("Librarian: %s:%s" % (LIBRHOST, LIBRPORT))
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
161
    log.info("Dry run: %s" % (dry_run))
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
162
    log.info("")
1716.1.211 by Christian Reis
De-lintify and add better exceptions to gina.py
163
5028.1.6 by David Murphy
Removed PackagePublishingPriority, PackagePublishingStatus, PackagePublishingPocket, PackageUploadStatus, & PackageUploadCustomFormat from canonical.lp.dbschema.
164
    if hasattr(PackagePublishingPocket, pocket.upper()):
165
        pocket = getattr(PackagePublishingPocket, pocket.upper())
1716.1.232 by Christian Reis
Set up an initial (empty) multiple-arch-component-pocket run, with a basic test. Also fix up my librarian query to not use selectOneBy. But I had to comment out the check, because staging and production are already polluted :-(
166
    else:
167
        log.error("Could not find a pocket schema for %s" % pocket)
168
        sys.exit(1)
169
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
170
    if component_override:
4753.4.2 by Julian Edwards
PEP-8 drives me NUTS.
171
        valid_components = [
172
            component.name for component in getUtility(IComponentSet)]
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
173
        if component_override not in valid_components:
174
            log.error("Could not find component %s" % component_override)
175
            sys.exit(1)
176
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
177
    kdb = None
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
178
    keyrings = None
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
179
    if KTDB:
5121.2.7 by Stuart Bishop
More required code changes
180
        kdb = Katie(KTDB, distroseries, dry_run)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
181
        keyrings = _get_keyring(keyrings_root)
182
183
    try:
6527.11.1 by Celso Providelo
go, gina, go ...
184
        arch_component_items = ArchiveComponentItems(
185
            package_root, pocket_distroseries, components, archs,
186
            source_only)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
187
    except MangledArchiveError:
5855.5.1 by Curtis Hovey
Migrate db configuration to lazr.config.
188
        log.exception(
189
            "Failed to analyze archive for %s" % pocket_distroseries)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
190
        sys.exit(1)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
191
192
    packages_map = PackagesMap(arch_component_items)
5121.2.7 by Stuart Bishop
More required code changes
193
    importer_handler = ImporterHandler(ztm, distro, distroseries,
2501 by Canonical.com Patch Queue Manager
Bring failed binary imports down from 472 to 6 by finding sources more aggressively. r=spiv
194
                                       dry_run, kdb, package_root, keyrings,
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
195
                                       pocket, component_override)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
196
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
197
    if spnames_only:
198
        log.info('Running in SourcePackageName-only mode...')
199
        for source in packages_map.src_map.itervalues():
200
            log.info('Ensuring %s name' % source['Package'])
1716.1.223 by Christian Reis
Checkpoint gina: the sourcepackage side is implemented and well-tested, over two releases, and over two runs of gina
201
            importer_handler.ensure_sourcepackagename(source['Package'])
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
202
        log.info('done')
7224.3.1 by Celso Providelo
fixing gina batching mode.
203
        return
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
204
205
    import_sourcepackages(packages_map, kdb, package_root, keyrings,
206
                          importer_handler)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
207
    importer_handler.commit()
208
209
    if source_only:
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
210
        log.info('Source only mode... done')
7224.3.1 by Celso Providelo
fixing gina batching mode.
211
        return
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
212
6527.11.1 by Celso Providelo
go, gina, go ...
213
    for archtag in archs:
214
        try:
215
            importer_handler.ensure_archinfo(archtag)
216
        except DataSetupError:
217
            log.exception("Database setup required for run on %s" % archtag)
218
            sys.exit(1)
219
1716.1.223 by Christian Reis
Checkpoint gina: the sourcepackage side is implemented and well-tested, over two releases, and over two runs of gina
220
    import_binarypackages(packages_map, kdb, package_root, keyrings,
221
                          importer_handler)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
222
    importer_handler.commit()
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
223
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
224
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
225
def import_sourcepackages(packages_map, kdb, package_root,
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
226
                          keyrings, importer_handler):
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
227
    # Goes over src_map importing the sourcepackages packages.
228
    count = 0
229
    npacks = len(packages_map.src_map)
1716.1.217 by Christian Reis
Fix up remaining SQL issues (manually tested by hacking up gina.py, improve gina.py logging and error output, some added language consistency
230
    log.info('%i Source Packages to be imported' % npacks)
1716.1.211 by Christian Reis
De-lintify and add better exceptions to gina.py
231
1716.1.227 by Christian Reis
Order packages by name when processing them, to obtain stable test output. Add a host of binary packages to hoary to ensure I have enough to test with. Check before importing binary packages that they already exist (as we do for source packages) to optimize processing time and output. Reorganize tests to be a bit more self-contained.
232
    for source in sorted(packages_map.src_map.values(),
233
                         key=lambda x: x.get("Package")):
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
234
        count += 1
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
235
        package_name = source.get("Package", "unknown")
236
        try:
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
237
            try:
238
                do_one_sourcepackage(source, kdb, package_root, keyrings,
239
                                     importer_handler)
5821.10.4 by Celso Providelo
fixing gina tests.
240
            except psycopg2.Error:
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
241
                log.exception("Database error: unable to create "
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
242
                              "SourcePackage for %s. Retrying once.."
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
243
                              % package_name)
244
                importer_handler.abort()
245
                time.sleep(15)
246
                do_one_sourcepackage(source, kdb, package_root, keyrings,
247
                                     importer_handler)
1716.1.229 by Christian Reis
Move encoding of person's displayname into packages. Add tests for version numbers for gcc-defaults, clean up code slightly. What remains: validating ensureBuild and _getBinary, and testing with multiple components, pockets and architectures
248
        except (InvalidVersionError, MissingRequiredArguments,
249
                DisplayNameDecodingError):
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
250
            log.exception("Unable to create SourcePackageData for %s" %
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
251
                          package_name)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
252
            continue
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
253
        except (PoolFileNotFound, ExecutionError):
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
254
            # Problems with katie db stuff of opening files
255
            log.exception("Error processing package files for %s" %
256
                          package_name)
257
            continue
5821.10.4 by Celso Providelo
fixing gina tests.
258
        except psycopg2.Error:
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
259
            log.exception("Database errors made me give up: unable to create "
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
260
                          "SourcePackage for %s" % package_name)
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
261
            importer_handler.abort()
262
            continue
1716.1.223 by Christian Reis
Checkpoint gina: the sourcepackage side is implemented and well-tested, over two releases, and over two runs of gina
263
        except MultiplePackageReleaseError:
264
            log.exception("Database duplication processing %s" %
265
                          package_name)
266
            continue
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
267
268
        if COUNTDOWN and count % COUNTDOWN == 0:
269
            log.warn('%i/%i sourcepackages processed' % (count, npacks))
1716.1.217 by Christian Reis
Fix up remaining SQL issues (manually tested by hacking up gina.py, improve gina.py logging and error output, some added language consistency
270
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
271
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
272
def do_one_sourcepackage(source, kdb, package_root, keyrings,
273
                         importer_handler):
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
274
    source_data = SourcePackageData(**source)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
275
    if importer_handler.preimport_sourcecheck(source_data):
276
        # Don't bother reading package information if the source package
277
        # already exists in the database
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
278
        log.info('%s already exists in the archive' % source_data.package)
279
        return
280
    source_data.process_package(kdb, package_root, keyrings)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
281
    source_data.ensure_complete(kdb)
282
    importer_handler.import_sourcepackage(source_data)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
283
    importer_handler.commit()
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
284
285
1716.1.223 by Christian Reis
Checkpoint gina: the sourcepackage side is implemented and well-tested, over two releases, and over two runs of gina
286
def import_binarypackages(packages_map, kdb, package_root, keyrings,
287
                          importer_handler):
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
288
    nosource = []
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
289
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
290
    # Run over all the architectures we have
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
291
    for archtag in packages_map.bin_map.keys():
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
292
        count = 0
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
293
        npacks = len(packages_map.bin_map[archtag])
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
294
        log.info('%i Binary Packages to be imported for %s' %
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
295
                 (npacks, archtag))
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
296
        # Go over binarypackages importing them for this architecture
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
297
        for binary in sorted(packages_map.bin_map[archtag].values(),
1716.1.227 by Christian Reis
Order packages by name when processing them, to obtain stable test output. Add a host of binary packages to hoary to ensure I have enough to test with. Check before importing binary packages that they already exist (as we do for source packages) to optimize processing time and output. Reorganize tests to be a bit more self-contained.
298
                             key=lambda x: x.get("Package")):
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
299
            count += 1
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
300
            package_name = binary.get("Package", "unknown")
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
301
            try:
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
302
                try:
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
303
                    do_one_binarypackage(binary, archtag, kdb, package_root,
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
304
                                         keyrings, importer_handler)
5821.10.4 by Celso Providelo
fixing gina tests.
305
                except psycopg2.Error:
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
306
                    log.exception("Database errors when importing a "
307
                                  "BinaryPackage for %s. Retrying once.."
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
308
                                  % package_name)
309
                    importer_handler.abort()
310
                    time.sleep(15)
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
311
                    do_one_binarypackage(binary, archtag, kdb, package_root,
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
312
                                         keyrings, importer_handler)
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
313
            except (InvalidVersionError, MissingRequiredArguments):
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
314
                log.exception("Unable to create BinaryPackageData for %s" %
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
315
                              package_name)
316
                continue
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
317
            except (PoolFileNotFound, ExecutionError):
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
318
                # Problems with katie db stuff of opening files
319
                log.exception("Error processing package files for %s" %
320
                              package_name)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
321
                continue
1716.1.226 by Christian Reis
Moving verification and parsing code over to packages.py, simplifying handlers.py. Also improved the way check_not_in_librarian communicates failures. Added some important XXXs that are a consequence of the use of Teri on the archive. All tests still pass
322
            except MultiplePackageReleaseError:
323
                log.exception("Database duplication processing %s" %
324
                              package_name)
325
                continue
5821.10.4 by Celso Providelo
fixing gina tests.
326
            except psycopg2.Error:
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
327
                log.exception("Database errors made me give up: unable to "
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
328
                              "create BinaryPackage for %s" % package_name)
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
329
                importer_handler.abort()
330
                continue
331
            except NoSourcePackageError:
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
332
                log.exception("Failed to create Binary Package for %s" %
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
333
                              package_name)
334
                nosource.append(binary)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
335
                continue
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
336
337
            if COUNTDOWN and count % COUNTDOWN == 0:
4664.1.1 by Curtis Hovey
Normalized comments for bug 3732.
338
                # XXX kiko 2005-10-23: untested
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
339
                log.warn('%i/%i binary packages processed' % (count, npacks))
340
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
341
        if nosource:
4664.1.1 by Curtis Hovey
Normalized comments for bug 3732.
342
            # XXX kiko 2005-10-23: untested
1716.1.241 by Christian Reis
Add support for locating license files that are prefixed with the binary package name (and add a package to test the feature with). Clean up changelog handling of package and version. Deal with the fact that selectOne* can raise an exception when encountering database corruption. Explicitly set SourcePackageRelease.format, and reorder the SPR attributes to check we are indeed sending in everything we should. Added a test for an invalid version. Refactor dsc and license handling so we don't do any more than we should in each of the calls to read_*.
343
            log.warn('%i source packages not found' % len(nosource))
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
344
            for pkg in nosource:
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
345
                log.warn(pkg)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
346
347
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
348
def do_one_binarypackage(binary, archtag, kdb, package_root, keyrings,
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
349
                         importer_handler):
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
350
    binary_data = BinaryPackageData(**binary)
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
351
    if importer_handler.preimport_binarycheck(archtag, binary_data):
1716.1.227 by Christian Reis
Order packages by name when processing them, to obtain stable test output. Add a host of binary packages to hoary to ensure I have enough to test with. Check before importing binary packages that they already exist (as we do for source packages) to optimize processing time and output. Reorganize tests to be a bit more self-contained.
352
        log.info('%s already exists in the archive' % binary_data.package)
353
        return
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
354
    binary_data.process_package(kdb, package_root, keyrings)
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
355
    importer_handler.import_binarypackage(archtag, binary_data)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
356
    importer_handler.commit()
357
358
359
if __name__ == "__main__":
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
360
    main()
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
361