~launchpad-pqm/launchpad/devel

10637.3.1 by Guilherme Salgado
Use the default python version instead of a hard-coded version
1
#!/usr/bin/python -S
8687.15.7 by Karl Fogel
Add the copyright header block to more 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
4935.3.7 by Curtis Hovey
Added bad name suppression to cronscripts.
6
# pylint: disable-msg=C0103,W0403
4829.1.1 by Jeroen Vermeulen
Implementing translation-statistics-sanity-checks spec.
7
8
"""Refresh and verify cached POFile translation statistics."""
9
5084.9.1 by Jeroen Vermeulen
Add pythonpath import.
10
import _pythonpath
11
8356.1.1 by Leonard Richardson
Partial move.
12
from lp.services.scripts.base import LaunchpadCronScript
8751.1.1 by Danilo Šegan
Store migration changes so far.
13
from lp.translations.scripts.verify_pofile_stats import (
14612.2.8 by William Grant
cronscripts
14
    VerifyPOFileStatsProcess,
15
    )
4829.1.1 by Jeroen Vermeulen
Implementing translation-statistics-sanity-checks spec.
16
17
18
class VerifyPOFileStats(LaunchpadCronScript):
4829.1.5 by Jeroen Vermeulen
Changes based on review.
19
    """Trawl `POFile` table, verifying and updating cached statistics."""
20
9046.4.1 by Jeroen Vermeulen
Make POFile stats updates a bit more performance-friendly.
21
    def add_my_options(self):
22
        self.parser.add_option('-i', '--start-id', dest='start_id',
23
            type='int',
24
            help="Verify from this POFile id upward.")
25
4829.1.1 by Jeroen Vermeulen
Implementing translation-statistics-sanity-checks spec.
26
    def main(self):
9046.4.1 by Jeroen Vermeulen
Make POFile stats updates a bit more performance-friendly.
27
        if self.options.start_id is not None:
28
            start_id = int(self.options.start_id)
29
        else:
30
            start_id = 0
31
32
        verifier = VerifyPOFileStatsProcess(
33
            self.txn, self.logger, start_at_id=start_id)
34
        verifier.run()
4829.1.1 by Jeroen Vermeulen
Implementing translation-statistics-sanity-checks spec.
35
36
37
if __name__ == '__main__':
5106.4.55 by Jeroen Vermeulen
Dedicated user for POFile statistics verifier.
38
    script = VerifyPOFileStats(name="pofile-stats", dbuser='pofilestats')
4829.1.1 by Jeroen Vermeulen
Implementing translation-statistics-sanity-checks spec.
39
    script.lock_and_run()