~launchpad-pqm/launchpad/devel

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
39
40
41
42
#!/usr/bin/python
# Copyright 2005 Canonical Ltd. All rights reserved.

import _pythonpath

import logging
import sys
from optparse import OptionParser

from canonical.lp import initZopeless
from canonical.launchpad.scripts import (
    execute_zcml_for_scripts, logger_options, logger as logger_from_options)
from canonical.launchpad.scripts.lockfile import LockFile
from canonical.launchpad.scripts.po_export_queue import process_queue

def main(args):
    parser = OptionParser()
    logger_options(parser, logging.WARNING)
    options, args = parser.parse_args()
    logger = logger_from_options(options)

    lockfile_path = '/var/lock/rosetta-export-queue.lock'
    lockfile = LockFile(lockfile_path, logger=logger)

    try:
        lockfile.acquire()
    except OSError:
        logger.info('Lockfile %s already exists, exiting.' % lockfile_path)
        return 0

    try:
        ztm = initZopeless()
        execute_zcml_for_scripts()
        process_queue(ztm, logger)
        logger.info('Done.')
        return 0
    finally:
        lockfile.release()

if __name__ == '__main__':
    sys.exit(main(sys.argv))