Merge lp:~stevenk/launchpad/kill-rpsd into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 15748
Proposed branch: lp:~stevenk/launchpad/kill-rpsd
Merge into: lp:launchpad
Diff against target: 216 lines (+6/-164)
3 files modified
cronscripts/rosetta-pofile-stats-daily.py (+0/-29)
lib/lp/translations/doc/pofile-verify-stats.txt (+1/-69)
lib/lp/translations/scripts/verify_pofile_stats.py (+5/-66)
To merge this branch: bzr merge lp:~stevenk/launchpad/kill-rpsd
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+114300@code.launchpad.net

Commit message

Remove cronscripts/rosetta-pofile-stats-daily.py and the horse it rode in on.

Description of the change

cronscripts/rosetta-pofile-stats-daily.py is unnecessary, has not been run for quite a while, interferes with FDT if it does want to get run, and has been replaced by a job. Delete it, with prejudice.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'cronscripts/rosetta-pofile-stats-daily.py'
2--- cronscripts/rosetta-pofile-stats-daily.py 2012-01-01 03:14:54 +0000
3+++ cronscripts/rosetta-pofile-stats-daily.py 1970-01-01 00:00:00 +0000
4@@ -1,29 +0,0 @@
5-#!/usr/bin/python -S
6-#
7-# Copyright 2009 Canonical Ltd. This software is licensed under the
8-# GNU Affero General Public License version 3 (see the file LICENSE).
9-
10-# pylint: disable-msg=W0403
11-
12-"""Refresh and verify cached statistics for recently touched POFiles."""
13-
14-import _pythonpath
15-
16-from lp.services.scripts.base import LaunchpadCronScript
17-from lp.translations.scripts.verify_pofile_stats import (
18- VerifyRecentPOFileStatsProcess,
19- )
20-
21-
22-class VerifyRecentPOFileStats(LaunchpadCronScript):
23- """Go through recently touched `POFile`s and update their statistics."""
24-
25- def main(self):
26- verifier = VerifyRecentPOFileStatsProcess(self.txn, self.logger)
27- verifier.run()
28-
29-
30-if __name__ == '__main__':
31- script = VerifyRecentPOFileStats(name="pofile-stats-daily",
32- dbuser='pofilestats_daily')
33- script.lock_and_run()
34
35=== modified file 'lib/lp/translations/doc/pofile-verify-stats.txt'
36--- lib/lp/translations/doc/pofile-verify-stats.txt 2011-12-29 05:29:36 +0000
37+++ lib/lp/translations/doc/pofile-verify-stats.txt 2012-08-06 22:19:28 +0000
38@@ -119,75 +119,6 @@
39 <BLANKLINE>
40 See the log file for detailed information.
41
42-Verify recently touched POFiles runs
43-------------------------------------
44-
45-A separate script is used to verify statistics on POFiles that have
46-been modified in the last week (or whatever number of days is configured
47-in rosetta_pofile_stats.days_considered_recent parameter).
48-
49- >>> from lp.translations.scripts.verify_pofile_stats import (
50- ... VerifyRecentPOFileStatsProcess)
51- >>> from datetime import datetime, timedelta
52- >>> import pytz
53- >>> from zope.security.proxy import removeSecurityProxy
54-
55-In default configuration, we are looking for files modified in the last
56-7 days.
57-
58- >>> from lp.services.config import config
59- >>> pofile_age = int(
60- ... config.rosetta_pofile_stats.days_considered_recent)
61- >>> pofile_age
62- 7
63-
64-We add two POFiles with incorrect statistics, with one of them last
65-modified 8 days ago, and another recently modified.
66-
67- >>> now = datetime.now(pytz.UTC)
68- >>> more_than_a_week_ago = now - timedelta(pofile_age + 1)
69- >>> pofile_recent = removeSecurityProxy(factory.makePOFile('sr'))
70- >>> pofile_recent.rosettacount = 9
71- >>> pofile_old = removeSecurityProxy(factory.makePOFile('sr'))
72- >>> pofile_old.date_changed = more_than_a_week_ago
73- >>> pofile_old.rosettacount = 9
74-
75-A run of `VerifyRecentPOFileStatsProcess` script fixes only the POFile
76-which was modified in the last week.
77-
78- >>> verifier = VerifyRecentPOFileStatsProcess(transaction, logger)
79- >>> verifier.run()
80- INFO Verifying stats of POFiles updated in the last 7 days.
81- INFO Verifying a total of 1 POFiles.
82- INFO POFile ...:
83- cached stats were (0, 0, 9, 0), recomputed as (0, 0, 0, 0)
84- INFO Done.
85-
86-We can see that stats have been updated in the recently touched POFile,
87-but not in the older one.
88-
89- >>> pofile_recent.rosettacount
90- 0
91- >>> pofile_old.rosettacount
92- 9
93-
94-
95-An actual script run also works, though it finds no errors since they were
96-all fixed already.
97-
98- >>> transaction.commit() # Ensure other process can see latest changes
99-
100- >>> from lp.testing.script import run_script
101- >>> (returncode, out, err) = run_script(
102- ... 'cronscripts/rosetta-pofile-stats-daily.py')
103- >>> print returncode
104- 0
105- >>> print err
106- INFO Creating lockfile: /var/lock/launchpad-pofile-stats-daily.lock
107- INFO Verifying stats of POFiles updated in the last ... days.
108- INFO Verifying a total of 1 POFiles.
109- INFO Done.
110-
111 Cron job
112 --------
113
114@@ -195,6 +126,7 @@
115 completes without finding any errors: the one we introduced earlier was
116 fixed by running the verifier directly.
117
118+ >>> from lp.testing.script import run_script
119 >>> (returncode, out, err) = run_script(
120 ... 'cronscripts/rosetta-pofile-stats.py', ['--start-id=99'])
121 >>> print returncode
122
123=== modified file 'lib/lp/translations/scripts/verify_pofile_stats.py'
124--- lib/lp/translations/scripts/verify_pofile_stats.py 2012-06-29 08:40:05 +0000
125+++ lib/lp/translations/scripts/verify_pofile_stats.py 2012-08-06 22:19:28 +0000
126@@ -6,16 +6,13 @@
127 """Verify (and refresh) `POFile`s' cached statistics."""
128
129 __metaclass__ = type
130-__all__ = ['VerifyPOFileStatsProcess']
131-
132-
133-from datetime import (
134- datetime,
135- timedelta,
136- )
137+__all__ = [
138+ 'VerifyPOFileStatsProcess',
139+ ]
140+
141+
142 import logging
143
144-import pytz
145 from zope.component import getUtility
146 from zope.interface import implements
147
148@@ -103,27 +100,6 @@
149 % (pofile.id, str(old_stats), str(new_stats)))
150
151
152-class QuickVerifier(Verifier):
153- """`ITunableLoop` to verify statistics on POFiles touched recently."""
154-
155- def __init__(self, transaction, logger, start_at_id=0):
156- super(QuickVerifier, self).__init__(transaction, logger, start_at_id)
157- days_considered_recent = int(
158- config.rosetta_pofile_stats.days_considered_recent)
159- cutoff_time = (
160- datetime.now(pytz.UTC) - timedelta(days_considered_recent))
161- self.touched_pofiles = self.pofileset.getPOFilesTouchedSince(
162- cutoff_time)
163- self.logger.info(
164- "Verifying a total of %d POFiles." % self.touched_pofiles.count())
165-
166- def getPOFilesBatch(self, chunk_size):
167- """Return a batch of POFiles to work with."""
168- pofiles = self.touched_pofiles[
169- self.total_checked: self.total_checked + int(chunk_size)]
170- return pofiles
171-
172-
173 class VerifyPOFileStatsProcess:
174 """Recompute & verify `POFile` translation statistics."""
175
176@@ -171,40 +147,3 @@
177 self.transaction.commit()
178
179 self.logger.info("Done.")
180-
181-
182-class VerifyRecentPOFileStatsProcess:
183- """Recompute & verify `POFile` translation statistics."""
184-
185- def __init__(self, transaction, logger=None):
186- self.transaction = transaction
187- self.logger = logger
188- if logger is None:
189- self.logger = logging.getLogger("pofile-stats-daily")
190-
191- def run(self):
192- self.logger.info(
193- "Verifying stats of POFiles updated in the last %s days." % (
194- config.rosetta_pofile_stats.days_considered_recent))
195- loop = QuickVerifier(self.transaction, self.logger)
196- iteration_duration = (
197- config.rosetta_pofile_stats.looptuner_iteration_duration)
198- DBLoopTuner(loop, iteration_duration).run()
199-
200- if loop.total_incorrect > 0 or loop.total_exceptions > 0:
201- # Not all statistics were correct, or there were failures while
202- # checking them. Email the admins.
203- template = get_email_template(
204- 'pofile-stats.txt', 'translations')
205- message = template % {
206- 'exceptions': loop.total_exceptions,
207- 'errors': loop.total_incorrect,
208- 'total': loop.total_checked}
209- simple_sendmail(
210- from_addr=config.canonical.noreply_from_address,
211- to_addrs=[config.launchpad.errors_address],
212- subject="POFile statistics errors (daily)",
213- body=MailWrapper().format(message))
214- self.transaction.commit()
215-
216- self.logger.info("Done.")