launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #15408
[Merge] lp:~stevenk/launchpad/fix-translations-opening-specify into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/fix-translations-opening-specify into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #778430 in Launchpad itself: "The copy-translations-from-parent script should really be restartable."
https://bugs.launchpad.net/launchpad/+bug/778430
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/fix-translations-opening-specify/+merge/155375
Rewrite the queries in fix-translations-opening to no longer hard code the series name, but to look it up. Fix an import thing in copy-translations-from-parent.
--
https://code.launchpad.net/~stevenk/launchpad/fix-translations-opening-specify/+merge/155375
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/fix-translations-opening-specify into lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg 2013-03-18 00:57:56 +0000
+++ database/schema/security.cfg 2013-03-25 23:58:23 +0000
@@ -1605,7 +1605,7 @@
public.karmaaction = SELECT
public.language = SELECT, INSERT
public.packaging = SELECT
-public.packagingjob = SELECT
+public.packagingjob = SELECT, DELETE
public.person = SELECT
public.pofile = SELECT, INSERT, UPDATE, DELETE
public.pofiletranslator = SELECT, INSERT, UPDATE, DELETE
=== modified file 'scripts/copy-translations-from-parent.py'
--- scripts/copy-translations-from-parent.py 2013-01-07 02:40:55 +0000
+++ scripts/copy-translations-from-parent.py 2013-03-25 23:58:23 +0000
@@ -1,6 +1,6 @@
#!/usr/bin/python -S
#
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Furnish distroseries with lacking translations that its parent does have.
@@ -16,6 +16,7 @@
from zope.component import getUtility
+from lp.registry.interfaces.distribution import IDistributionSet
from lp.services.scripts.base import LaunchpadCronScript
from lp.translations.scripts.copy_distroseries_translations import (
copy_distroseries_translations,
@@ -41,14 +42,10 @@
def _getTargetSeries(self):
"""Retrieve target `DistroSeries`."""
- from lp.registry.interfaces.distribution import IDistributionSet
- distro = self.options.distro
series = self.options.series
- return getUtility(IDistributionSet)[distro][series]
+ return getUtility(IDistributionSet)[self.options.distro][series]
def main(self):
- from lp.registry.interfaces.distribution import IDistributionSet
- distribution = getUtility(IDistributionSet)[self.options.distro]
series = self._getTargetSeries()
# Both translation UI and imports for this series should be blocked
@@ -96,9 +93,6 @@
if __name__ == '__main__':
-
script = TranslationsCopier(
'copy-missing-translations', dbuser='translations_distroseries_copy')
-
script.lock_and_run()
-
=== modified file 'scripts/fix-translations-opening.py'
--- scripts/fix-translations-opening.py 2012-09-28 06:25:44 +0000
+++ scripts/fix-translations-opening.py 2013-03-25 23:58:23 +0000
@@ -1,4 +1,7 @@
#!/usr/bin/python -S
+#
+# Copyright 2012-2013 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -7,11 +10,9 @@
from zope.component import getUtility
from zope.interface import implements
-from lp.services.database.interfaces import (
- IStoreSelector,
- MAIN_STORE,
- MASTER_FLAVOR,
- )
+from lp.registry.interfaces.distribution import IDistributionSet
+from lp.registry.model.distroseries import DistroSeries
+from lp.services.database.lpstorm import IMasterStore
from lp.services.looptuner import (
DBLoopTuner,
ITunableLoop,
@@ -19,17 +20,6 @@
from lp.services.scripts.base import LaunchpadScript
-series_name = 'quantal'
-
-select_series = """\
-SELECT DistroSeries.id
- FROM DistroSeries
- JOIN Distribution ON
- Distribution.id = DistroSeries.distribution
- WHERE Distribution.name = 'ubuntu'
- AND DistroSeries.name = '%s'
-""" % series_name
-
delete_pofiletranslator = """\
DELETE FROM POFileTranslator
WHERE POFileTranslator.id IN (
@@ -37,9 +27,9 @@
FROM POFileTranslator, POFile, POTemplate
WHERE POFileTranslator.pofile = POFile.id
AND POFile.potemplate = POTemplate.id
- AND POTemplate.distroseries = (%s)
+ AND POTemplate.distroseries = ?
LIMIT ?)
-""" % select_series
+"""
null_translationimportqueueentry_pofile = """\
UPDATE TranslationImportQueueEntry
@@ -49,9 +39,9 @@
FROM TranslationImportQueueEntry, POFile, POTemplate
WHERE TranslationImportQueueEntry.pofile = POFile.id
AND POFile.potemplate = POTemplate.id
- AND POTemplate.distroseries = (%s)
+ AND POTemplate.distroseries = ?
LIMIT ?)
-""" % select_series
+"""
delete_pofile = """\
DELETE FROM POFile
@@ -59,9 +49,9 @@
SELECT POFile.id
FROM POFile, POTemplate
WHERE POFile.potemplate = POTemplate.id
- AND POTemplate.distroseries = (%s)
+ AND POTemplate.distroseries = ?
LIMIT ?)
-""" % select_series
+"""
delete_translationtemplateitem = """\
DELETE FROM TranslationTemplateItem
@@ -69,9 +59,9 @@
SELECT TranslationTemplateItem.id
FROM TranslationTemplateItem, POTemplate
WHERE TranslationTemplateItem.potemplate = POTemplate.id
- AND POTemplate.distroseries = (%s)
+ AND POTemplate.distroseries = ?
LIMIT ?)
-""" % select_series
+"""
delete_packagingjob = """\
DELETE FROM PackagingJob
@@ -79,9 +69,9 @@
SELECT PackagingJob.id
FROM PackagingJob, POTemplate
WHERE PackagingJob.potemplate = POTemplate.id
- AND POTemplate.distroseries = (%s)
+ AND POTemplate.distroseries = ?
LIMIT ?)
-""" % select_series
+"""
null_translationimportqueueentry_potemplate = """\
UPDATE TranslationImportQueueEntry
@@ -90,18 +80,18 @@
SELECT TranslationImportQueueEntry.id
FROM TranslationImportQueueEntry, POTemplate
WHERE TranslationImportQueueEntry.potemplate = POTemplate.id
- AND POTemplate.distroseries = (%s)
+ AND POTemplate.distroseries = ?
LIMIT ?)
-""" % select_series
+"""
delete_potemplate = """\
DELETE FROM POTemplate
WHERE POTemplate.id IN (
SELECT POTemplate.id
FROM POTemplate
- WHERE POTemplate.distroseries = (%s)
+ WHERE POTemplate.distroseries = ?
LIMIT ?)
-""" % select_series
+"""
statements = [
delete_pofiletranslator,
@@ -118,8 +108,9 @@
implements(ITunableLoop)
- def __init__(self, statement, logger):
+ def __init__(self, statement, series, logger):
self.statement = statement
+ self.series = series
self.logger = logger
self.done = False
@@ -128,11 +119,10 @@
def __call__(self, chunk_size):
self.logger.info(
- "%s (limited to %d rows)",
- self.statement.splitlines()[0],
+ "%s (limited to %d rows)", self.statement.splitlines()[0],
chunk_size)
- store = getUtility(IStoreSelector).get(MAIN_STORE, MASTER_FLAVOR)
- result = store.execute(self.statement, (chunk_size,))
+ store = IMasterStore(DistroSeries)
+ result = store.execute(self.statement, (self.series.id, chunk_size,))
self.done = (result.rowcount == 0)
self.logger.info(
"%d rows deleted (%s)", result.rowcount,
@@ -142,17 +132,23 @@
class WipeSeriesTranslationsScript(LaunchpadScript):
- description = "Wipe Ubuntu %s's translations." % series_name.title()
+ description = "Wipe translations for a series."
def add_my_options(self):
- self.parser.epilog = (
- "Before running this script you must `GRANT DELETE ON TABLE "
- "PackagingJob TO rosettaadmin` and afterwards you ought to "
- "`REVOKE DELETE ON PackagingJob FROM rosettaadmin`.")
+ self.parser.add_option('-d', '--distribution', dest='distro',
+ default='ubuntu',
+ help='Name of distribution to delete translations in.')
+ self.parser.add_option('-s', '--series', dest='series',
+ help='Name of distroseries whose translations should be removed')
+
+ def _getTargetSeries(self):
+ series = self.options.series
+ return getUtility(IDistributionSet)[self.options.distro][series]
def main(self):
+ series = self._getTargetSeries()
for statement in statements:
- delete = ExecuteLoop(statement, self.logger)
+ delete = ExecuteLoop(statement, series, self.logger)
tuner = DBLoopTuner(delete, 2.0, maximum_chunk_size=5000)
tuner.run()
Follow ups