~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/scripts/garbo.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2012-01-05 05:05:42 UTC
  • mfrom: (14632.1.5 implied-account)
  • Revision ID: launchpad@pqm.canonical.com-20120105050542-b4m54slx2mqa8htl
[r=wgrant][no-qa] EmailAddressSet.new now infers account from person
        if not specified explicitly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
    MAIN_STORE,
87
87
    MASTER_FLAVOR,
88
88
    )
89
 
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
90
89
from lp.translations.interfaces.potemplate import IPOTemplateSet
91
90
from lp.translations.model.potmsgset import POTMsgSet
92
91
from lp.translations.model.potranslation import POTranslation
902
901
        self._update_oldest()
903
902
 
904
903
 
905
 
class SourcePackageReleaseDscBinariesUpdater(TunableLoop):
906
 
    """Fix incorrect values for SourcePackageRelease.dsc_binaries."""
907
 
 
908
 
    maximum_chunk_size = 1000
909
 
 
910
 
    def __init__(self, log, abort_time=None):
911
 
        super(SourcePackageReleaseDscBinariesUpdater, self).__init__(
912
 
            log, abort_time)
913
 
        self.store = IMasterStore(SourcePackageRelease)
914
 
        self.ids = list(
915
 
            self.store.find(
916
 
                SourcePackageRelease.id,
917
 
                # Get all SPR IDs which have an incorrectly-separated
918
 
                # dsc_binaries value (space rather than comma-space).
919
 
                SQL("dsc_binaries ~ '[a-z0-9+.-] '"),
920
 
                # Skip rows with dsc_binaries in dependency relationship
921
 
                # format.  This is a different bug.
922
 
                SQL("dsc_binaries NOT LIKE '%(%'")))
923
 
 
924
 
    def isDone(self):
925
 
        """See `TunableLoop`."""
926
 
        return len(self.ids) == 0
927
 
 
928
 
    def __call__(self, chunk_size):
929
 
        """See `TunableLoop`."""
930
 
        chunk_size = int(chunk_size + 0.5)
931
 
        chunk_ids = self.ids[:chunk_size]
932
 
        del self.ids[:chunk_size]
933
 
        self.store.execute("""
934
 
            UPDATE SourcePackageRelease
935
 
            SET dsc_binaries = regexp_replace(
936
 
                dsc_binaries, '([a-z0-9+.-]) ', E'\\\\1, ', 'g')
937
 
            WHERE id IN %s""" % sqlvalues(chunk_ids), noresult=True)
938
 
        transaction.commit()
939
 
 
940
 
 
941
904
class SuggestiveTemplatesCacheUpdater(TunableLoop):
942
905
    """Refresh the SuggestivePOTemplate cache.
943
906
 
1302
1265
        ObsoleteBugAttachmentPruner,
1303
1266
        OldTimeLimitedTokenDeleter,
1304
1267
        RevisionAuthorEmailLinker,
1305
 
        SourcePackageReleaseDscBinariesUpdater,
1306
1268
        SuggestiveTemplatesCacheUpdater,
1307
1269
        POTranslationPruner,
1308
1270
        UnusedPOTMsgSetPruner,