~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
1845 by Canonical.com Patch Queue Manager
translation file downloading backend [r=Salgado]
7
2125 by Canonical.com Patch Queue Manager
[r=bjornt] Cronscript refactorings
8
import _pythonpath
9
5842.1.1 by James Henstridge
Rename the transaction isolation level constants to match the psycopg2
10
from canonical.database.sqlbase import ISOLATION_LEVEL_READ_COMMITTED
12189.3.1 by Jeroen Vermeulen
Avoid long-running master transactions during translations export.
11
from canonical.launchpad.webapp.dbpolicy import SlaveDatabasePolicy
8751.1.1 by Danilo Šegan
Store migration changes so far.
12
from lp.translations.scripts.po_export_queue import process_queue
8356.1.1 by Leonard Richardson
Partial move.
13
from lp.services.scripts.base import LaunchpadCronScript
4264.2.1 by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it
14
15
16
class RosettaExportQueue(LaunchpadCronScript):
12189.3.1 by Jeroen Vermeulen
Avoid long-running master transactions during translations export.
17
    """Translation exports."""
18
3691.348.18 by kiko
Convert most other scripts; 6 remain, of which one looks like it's going to be a bit tricky...
19
    def main(self):
12189.3.1 by Jeroen Vermeulen
Avoid long-running master transactions during translations export.
20
        with SlaveDatabasePolicy():
21
            process_queue(self.txn, self.logger)
3691.348.18 by kiko
Convert most other scripts; 6 remain, of which one looks like it's going to be a bit tricky...
22
1845 by Canonical.com Patch Queue Manager
translation file downloading backend [r=Salgado]
23
24
if __name__ == '__main__':
3691.348.18 by kiko
Convert most other scripts; 6 remain, of which one looks like it's going to be a bit tricky...
25
    script = RosettaExportQueue('rosetta-export-queue', dbuser='poexport')
12415.1.1 by William Grant
Stop using txn.set_isolation_level in scripts... run() has an argument for that purpose.
26
    script.lock_and_run(isolation=ISOLATION_LEVEL_READ_COMMITTED)