3944.1.1
by Francis J. Lacoste
Use system version python2.4 for scripts. |
1 |
#!/usr/bin/python2.4
|
4422.3.1
by Jeroen Vermeulen
Limit PO import cron script's runtime to "a bit over 8 minutes." |
2 |
# Copyright 2004-2007 Canonical Ltd. All rights reserved.
|
4935.3.7
by Curtis Hovey
Added bad name suppression to cronscripts. |
3 |
# pylint: disable-msg=C0103,W0403
|
953
by Canonical.com Patch Queue Manager
Added the raw po/pot import daemon |
4 |
|
2125
by Canonical.com Patch Queue Manager
[r=bjornt] Cronscript refactorings |
5 |
import _pythonpath |
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
6 |
|
1681.1.134
by Stuart Bishop
Make poattach and poimport connect as the correct database users |
7 |
from canonical.config import config |
5842.1.1
by James Henstridge
Rename the transaction isolation level constants to match the psycopg2 |
8 |
from canonical.database.sqlbase import ISOLATION_LEVEL_READ_COMMITTED |
2570.1.7
by Carlos Perello Marin
Lots of fixes + new code + tests updates |
9 |
from canonical.launchpad.scripts.po_import import ImportProcess |
4264.2.1
by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it |
10 |
from canonical.launchpad.scripts.base import LaunchpadCronScript |
11 |
||
4422.3.1
by Jeroen Vermeulen
Limit PO import cron script's runtime to "a bit over 8 minutes." |
12 |
# Time goal for this run. It is not exact. The script will run for longer
|
13 |
# than this time, but will know to stop taking on new batches of imports.
|
|
14 |
# Since script is run every 9 or 10 minutes, we set the "alarm" at 8 minutes.
|
|
15 |
# That leaves a bit of time to complete the last ongoing batch of imports.
|
|
4422.3.3
by Jeroen Vermeulen
More changes based on review (and thanks JamesH) |
16 |
SECONDS_TO_RUN = 8 * 60 |
4264.2.1
by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it |
17 |
|
18 |
class RosettaPOImporter(LaunchpadCronScript): |
|
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): |
5842.1.1
by James Henstridge
Rename the transaction isolation level constants to match the psycopg2 |
20 |
self.txn.set_isolation_level(ISOLATION_LEVEL_READ_COMMITTED) |
4422.3.2
by Jeroen Vermeulen
Cosmetic changes based on review |
21 |
process = ImportProcess(self.txn, self.logger, SECONDS_TO_RUN) |
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 |
self.logger.debug('Starting the import process') |
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
23 |
process.run() |
3691.348.18
by kiko
Convert most other scripts; 6 remain, of which one looks like it's going to be a bit tricky... |
24 |
self.logger.debug('Finished the import process') |
25 |
||
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
26 |
|
27 |
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... |
28 |
script = RosettaPOImporter('rosetta-poimport', |
5855.5.1
by Curtis Hovey
Migrate db configuration to lazr.config. |
29 |
dbuser=config.poimport.dbuser) |
3691.8.59
by Carlos Perello Marin
Prevent unneeded noise from the poimport script |
30 |
script.lock_or_quit() |
3691.8.60
by Carlos Perello Marin
If you commit your changes... they will be actually merged... |
31 |
try: |
32 |
script.run() |
|
33 |
finally: |
|
34 |
script.unlock() |
|
3691.348.18
by kiko
Convert most other scripts; 6 remain, of which one looks like it's going to be a bit tricky... |
35 |