~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 (
4829.1.2 by Jeroen Vermeulen
Also try running cron script.
14
    VerifyPOFileStatsProcess)
4829.1.1 by Jeroen Vermeulen
Implementing translation-statistics-sanity-checks spec.
15
16
17
class VerifyPOFileStats(LaunchpadCronScript):
4829.1.5 by Jeroen Vermeulen
Changes based on review.
18
    """Trawl `POFile` table, verifying and updating cached statistics."""
19
9046.4.1 by Jeroen Vermeulen
Make POFile stats updates a bit more performance-friendly.
20
    def add_my_options(self):
21
        self.parser.add_option('-i', '--start-id', dest='start_id',
22
            type='int',
23
            help="Verify from this POFile id upward.")
24
4829.1.1 by Jeroen Vermeulen
Implementing translation-statistics-sanity-checks spec.
25
    def main(self):
9046.4.1 by Jeroen Vermeulen
Make POFile stats updates a bit more performance-friendly.
26
        if self.options.start_id is not None:
27
            start_id = int(self.options.start_id)
28
        else:
29
            start_id = 0
30
31
        verifier = VerifyPOFileStatsProcess(
32
            self.txn, self.logger, start_at_id=start_id)
33
        verifier.run()
4829.1.1 by Jeroen Vermeulen
Implementing translation-statistics-sanity-checks spec.
34
35
36
if __name__ == '__main__':
5106.4.55 by Jeroen Vermeulen
Dedicated user for POFile statistics verifier.
37
    script = VerifyPOFileStats(name="pofile-stats", dbuser='pofilestats')
4829.1.1 by Jeroen Vermeulen
Implementing translation-statistics-sanity-checks spec.
38
    script.lock_and_run()