1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/usr/bin/python2.4
#
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
# pylint: disable-msg=C0103,W0403
import _pythonpath
from canonical.config import config
from canonical.database.sqlbase import ISOLATION_LEVEL_READ_COMMITTED
from lp.translations.scripts.po_import import ImportProcess
from lp.services.scripts.base import LaunchpadCronScript
# Time goal for this run. It is not exact. The script will run for longer
# than this time, but will know to stop taking on new batches of imports.
# Since script is run every 9 or 10 minutes, we set the "alarm" at 8 minutes.
# That leaves a bit of time to complete the last ongoing batch of imports.
SECONDS_TO_RUN = 8 * 60
class RosettaPOImporter(LaunchpadCronScript):
def main(self):
self.txn.set_isolation_level(ISOLATION_LEVEL_READ_COMMITTED)
process = ImportProcess(self.txn, self.logger, SECONDS_TO_RUN)
self.logger.debug('Starting the import process')
process.run()
self.logger.debug('Finished the import process')
if __name__ == '__main__':
script = RosettaPOImporter('rosetta-poimport',
dbuser=config.poimport.dbuser)
script.lock_or_quit()
try:
script.run()
finally:
script.unlock()
|