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
=== removed file 'cronscripts/rosetta-pofile-stats-daily.py'
--- cronscripts/rosetta-pofile-stats-daily.py 2012-01-01 03:14:54 +0000
+++ cronscripts/rosetta-pofile-stats-daily.py 1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
1#!/usr/bin/python -S
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
6# pylint: disable-msg=W0403
7
8"""Refresh and verify cached statistics for recently touched POFiles."""
9
10import _pythonpath
11
12from lp.services.scripts.base import LaunchpadCronScript
13from lp.translations.scripts.verify_pofile_stats import (
14 VerifyRecentPOFileStatsProcess,
15 )
16
17
18class VerifyRecentPOFileStats(LaunchpadCronScript):
19 """Go through recently touched `POFile`s and update their statistics."""
20
21 def main(self):
22 verifier = VerifyRecentPOFileStatsProcess(self.txn, self.logger)
23 verifier.run()
24
25
26if __name__ == '__main__':
27 script = VerifyRecentPOFileStats(name="pofile-stats-daily",
28 dbuser='pofilestats_daily')
29 script.lock_and_run()
300
=== modified file 'lib/lp/translations/doc/pofile-verify-stats.txt'
--- lib/lp/translations/doc/pofile-verify-stats.txt 2011-12-29 05:29:36 +0000
+++ lib/lp/translations/doc/pofile-verify-stats.txt 2012-08-06 22:19:28 +0000
@@ -119,75 +119,6 @@
119 <BLANKLINE>119 <BLANKLINE>
120 See the log file for detailed information.120 See the log file for detailed information.
121121
122Verify recently touched POFiles runs
123------------------------------------
124
125A separate script is used to verify statistics on POFiles that have
126been modified in the last week (or whatever number of days is configured
127in rosetta_pofile_stats.days_considered_recent parameter).
128
129 >>> from lp.translations.scripts.verify_pofile_stats import (
130 ... VerifyRecentPOFileStatsProcess)
131 >>> from datetime import datetime, timedelta
132 >>> import pytz
133 >>> from zope.security.proxy import removeSecurityProxy
134
135In default configuration, we are looking for files modified in the last
1367 days.
137
138 >>> from lp.services.config import config
139 >>> pofile_age = int(
140 ... config.rosetta_pofile_stats.days_considered_recent)
141 >>> pofile_age
142 7
143
144We add two POFiles with incorrect statistics, with one of them last
145modified 8 days ago, and another recently modified.
146
147 >>> now = datetime.now(pytz.UTC)
148 >>> more_than_a_week_ago = now - timedelta(pofile_age + 1)
149 >>> pofile_recent = removeSecurityProxy(factory.makePOFile('sr'))
150 >>> pofile_recent.rosettacount = 9
151 >>> pofile_old = removeSecurityProxy(factory.makePOFile('sr'))
152 >>> pofile_old.date_changed = more_than_a_week_ago
153 >>> pofile_old.rosettacount = 9
154
155A run of `VerifyRecentPOFileStatsProcess` script fixes only the POFile
156which was modified in the last week.
157
158 >>> verifier = VerifyRecentPOFileStatsProcess(transaction, logger)
159 >>> verifier.run()
160 INFO Verifying stats of POFiles updated in the last 7 days.
161 INFO Verifying a total of 1 POFiles.
162 INFO POFile ...:
163 cached stats were (0, 0, 9, 0), recomputed as (0, 0, 0, 0)
164 INFO Done.
165
166We can see that stats have been updated in the recently touched POFile,
167but not in the older one.
168
169 >>> pofile_recent.rosettacount
170 0
171 >>> pofile_old.rosettacount
172 9
173
174
175An actual script run also works, though it finds no errors since they were
176all fixed already.
177
178 >>> transaction.commit() # Ensure other process can see latest changes
179
180 >>> from lp.testing.script import run_script
181 >>> (returncode, out, err) = run_script(
182 ... 'cronscripts/rosetta-pofile-stats-daily.py')
183 >>> print returncode
184 0
185 >>> print err
186 INFO Creating lockfile: /var/lock/launchpad-pofile-stats-daily.lock
187 INFO Verifying stats of POFiles updated in the last ... days.
188 INFO Verifying a total of 1 POFiles.
189 INFO Done.
190
191Cron job122Cron job
192--------123--------
193124
@@ -195,6 +126,7 @@
195completes without finding any errors: the one we introduced earlier was126completes without finding any errors: the one we introduced earlier was
196fixed by running the verifier directly.127fixed by running the verifier directly.
197128
129 >>> from lp.testing.script import run_script
198 >>> (returncode, out, err) = run_script(130 >>> (returncode, out, err) = run_script(
199 ... 'cronscripts/rosetta-pofile-stats.py', ['--start-id=99'])131 ... 'cronscripts/rosetta-pofile-stats.py', ['--start-id=99'])
200 >>> print returncode132 >>> print returncode
201133
=== modified file 'lib/lp/translations/scripts/verify_pofile_stats.py'
--- lib/lp/translations/scripts/verify_pofile_stats.py 2012-06-29 08:40:05 +0000
+++ lib/lp/translations/scripts/verify_pofile_stats.py 2012-08-06 22:19:28 +0000
@@ -6,16 +6,13 @@
6"""Verify (and refresh) `POFile`s' cached statistics."""6"""Verify (and refresh) `POFile`s' cached statistics."""
77
8__metaclass__ = type8__metaclass__ = type
9__all__ = ['VerifyPOFileStatsProcess']9__all__ = [
1010 'VerifyPOFileStatsProcess',
1111 ]
12from datetime import (12
13 datetime,13
14 timedelta,
15 )
16import logging14import logging
1715
18import pytz
19from zope.component import getUtility16from zope.component import getUtility
20from zope.interface import implements17from zope.interface import implements
2118
@@ -103,27 +100,6 @@
103 % (pofile.id, str(old_stats), str(new_stats)))100 % (pofile.id, str(old_stats), str(new_stats)))
104101
105102
106class QuickVerifier(Verifier):
107 """`ITunableLoop` to verify statistics on POFiles touched recently."""
108
109 def __init__(self, transaction, logger, start_at_id=0):
110 super(QuickVerifier, self).__init__(transaction, logger, start_at_id)
111 days_considered_recent = int(
112 config.rosetta_pofile_stats.days_considered_recent)
113 cutoff_time = (
114 datetime.now(pytz.UTC) - timedelta(days_considered_recent))
115 self.touched_pofiles = self.pofileset.getPOFilesTouchedSince(
116 cutoff_time)
117 self.logger.info(
118 "Verifying a total of %d POFiles." % self.touched_pofiles.count())
119
120 def getPOFilesBatch(self, chunk_size):
121 """Return a batch of POFiles to work with."""
122 pofiles = self.touched_pofiles[
123 self.total_checked: self.total_checked + int(chunk_size)]
124 return pofiles
125
126
127class VerifyPOFileStatsProcess:103class VerifyPOFileStatsProcess:
128 """Recompute & verify `POFile` translation statistics."""104 """Recompute & verify `POFile` translation statistics."""
129105
@@ -171,40 +147,3 @@
171 self.transaction.commit()147 self.transaction.commit()
172148
173 self.logger.info("Done.")149 self.logger.info("Done.")
174
175
176class VerifyRecentPOFileStatsProcess:
177 """Recompute & verify `POFile` translation statistics."""
178
179 def __init__(self, transaction, logger=None):
180 self.transaction = transaction
181 self.logger = logger
182 if logger is None:
183 self.logger = logging.getLogger("pofile-stats-daily")
184
185 def run(self):
186 self.logger.info(
187 "Verifying stats of POFiles updated in the last %s days." % (
188 config.rosetta_pofile_stats.days_considered_recent))
189 loop = QuickVerifier(self.transaction, self.logger)
190 iteration_duration = (
191 config.rosetta_pofile_stats.looptuner_iteration_duration)
192 DBLoopTuner(loop, iteration_duration).run()
193
194 if loop.total_incorrect > 0 or loop.total_exceptions > 0:
195 # Not all statistics were correct, or there were failures while
196 # checking them. Email the admins.
197 template = get_email_template(
198 'pofile-stats.txt', 'translations')
199 message = template % {
200 'exceptions': loop.total_exceptions,
201 'errors': loop.total_incorrect,
202 'total': loop.total_checked}
203 simple_sendmail(
204 from_addr=config.canonical.noreply_from_address,
205 to_addrs=[config.launchpad.errors_address],
206 subject="POFile statistics errors (daily)",
207 body=MailWrapper().format(message))
208 self.transaction.commit()
209
210 self.logger.info("Done.")