1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
1 |
#!/usr/bin/env python
|
2 |
# Copyright 2005 Canonical Ltd. All rights reserved.
|
|
3 |
||
2125
by Canonical.com Patch Queue Manager
[r=bjornt] Cronscript refactorings |
4 |
import _pythonpath |
5 |
||
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
6 |
import sys |
7 |
from optparse import OptionParser |
|
8 |
||
1681.1.134
by Stuart Bishop
Make poattach and poimport connect as the correct database users |
9 |
from canonical.config import config |
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
10 |
from canonical.lp import initZopeless |
11 |
from canonical.launchpad.scripts.lockfile import LockFile |
|
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
12 |
from canonical.launchpad.scripts.rosetta import URLOpener, attach |
13 |
from canonical.launchpad.scripts import (execute_zcml_for_scripts, logger, |
|
14 |
logger_options) |
|
1513
by Canonical.com Patch Queue Manager
Merged LaunchpadPackagePoAttach spec implementation needed for Hoary Translations |
15 |
|
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
16 |
default_lock_file = '/var/lock/rosetta-package-po-attach.lock' |
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
17 |
|
1702
by Canonical.com Patch Queue Manager
PO attach functional test, plus miscellaneous fixes (r=Steve) |
18 |
def parse_options(args): |
19 |
"""Parse a set of command line options.
|
|
20 |
||
21 |
Returns an optparse.Values object.
|
|
22 |
"""
|
|
23 |
||
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
24 |
parser = OptionParser() |
25 |
parser.add_option("-l", "--lockfile", dest="lockfilename", |
|
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
26 |
default=default_lock_file, |
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
27 |
help="The file the script should use to lock the process.") |
1513
by Canonical.com Patch Queue Manager
Merged LaunchpadPackagePoAttach spec implementation needed for Hoary Translations |
28 |
parser.add_option("-a", "--archive", dest="archive_uri", |
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
29 |
default="http://people.ubuntu.com/~lamont/translations/", |
1513
by Canonical.com Patch Queue Manager
Merged LaunchpadPackagePoAttach spec implementation needed for Hoary Translations |
30 |
help="The location of the archive from which to get translations") |
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
31 |
|
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
32 |
# Add the verbose/quiet options.
|
33 |
logger_options(parser) |
|
34 |
||
1702
by Canonical.com Patch Queue Manager
PO attach functional test, plus miscellaneous fixes (r=Steve) |
35 |
(options, args) = parser.parse_args(args) |
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
36 |
|
37 |
return options |
|
38 |
||
2125
by Canonical.com Patch Queue Manager
[r=bjornt] Cronscript refactorings |
39 |
|
1702
by Canonical.com Patch Queue Manager
PO attach functional test, plus miscellaneous fixes (r=Steve) |
40 |
def main(argv): |
41 |
options = parse_options(argv[1:]) |
|
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
42 |
|
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
43 |
logger_object = logger(options, 'rosetta-package-po-attach') |
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
44 |
|
45 |
# Create a lock file so we don't have two daemons running at the same time.
|
|
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
46 |
lockfile = LockFile(options.lockfilename, logger=logger_object) |
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
47 |
try: |
48 |
lockfile.acquire() |
|
49 |
except OSError: |
|
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
50 |
logger_object.info("lockfile %s already exists, exiting", |
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
51 |
options.lockfilename) |
1702
by Canonical.com Patch Queue Manager
PO attach functional test, plus miscellaneous fixes (r=Steve) |
52 |
return 0 |
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
53 |
|
54 |
try: |
|
2125
by Canonical.com Patch Queue Manager
[r=bjornt] Cronscript refactorings |
55 |
# Setup zcml machinery to be able to use getUtility
|
56 |
execute_zcml_for_scripts() |
|
1681.1.134
by Stuart Bishop
Make poattach and poimport connect as the correct database users |
57 |
ztm = initZopeless(dbuser=config.rosetta.poattach.dbuser) |
2125
by Canonical.com Patch Queue Manager
[r=bjornt] Cronscript refactorings |
58 |
urlopener = URLOpener() |
59 |
||
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
60 |
attach(urlopener, options.archive_uri, ztm, logger_object) |
2125
by Canonical.com Patch Queue Manager
[r=bjornt] Cronscript refactorings |
61 |
return 0 |
62 |
finally: |
|
1513
by Canonical.com Patch Queue Manager
Merged LaunchpadPackagePoAttach spec implementation needed for Hoary Translations |
63 |
# Release the lock for the next invocation.
|
1333
by Canonical.com Patch Queue Manager
Merged all my work from last two weeks about po tarballs attach from buildd into Rosetta. Reviewed by Steve |
64 |
lockfile.release() |
1513
by Canonical.com Patch Queue Manager
Merged LaunchpadPackagePoAttach spec implementation needed for Hoary Translations |
65 |
|
1702
by Canonical.com Patch Queue Manager
PO attach functional test, plus miscellaneous fixes (r=Steve) |
66 |
|
67 |
if __name__ == '__main__': |
|
68 |
sys.exit(main(sys.argv)) |
|
1513
by Canonical.com Patch Queue Manager
Merged LaunchpadPackagePoAttach spec implementation needed for Hoary Translations |
69 |