~launchpad-pqm/launchpad/devel

10637.3.7 by Guilherme Salgado
merge devel
1
#!/usr/bin/python -S
8687.15.9 by Karl Fogel
Add the copyright header block to more files (everything under database/).
2
#
13980.2.1 by Jeroen Vermeulen
Lint. Lots of lint.
3
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
8687.15.9 by Karl Fogel
Add the copyright header block to more files (everything under database/).
4
# GNU Affero General Public License version 3 (see the file LICENSE).
5799.1.59 by Stuart Bishop
Generate preamble for manual slonik usage.
5
6
"""Generate a preamble for slonik(1) scripts based on the current LPCONFIG.
7
"""
8
9
__metaclass__ = type
10
__all__ = []
11
14606.3.5 by William Grant
Reformat
12
import _pythonpath
13
13980.2.1 by Jeroen Vermeulen
Lint. Lots of lint.
14
from optparse import OptionParser
15
import time
16
14606.3.1 by William Grant
Merge canonical.database into lp.services.database.
17
from lp.services import scripts
14605.1.1 by Curtis Hovey
Moved canonical.config to lp.services.
18
from lp.services.config import config
14606.3.1 by William Grant
Merge canonical.database into lp.services.database.
19
from lp.services.database.sqlbase import connect
14606.3.5 by William Grant
Reformat
20
import replication.helpers
7675.85.2 by Jonathan Lange
Undo revision generated by step 2 of process.
21
5799.1.59 by Stuart Bishop
Generate preamble for manual slonik usage.
22
23
if __name__ == '__main__':
7675.85.2 by Jonathan Lange
Undo revision generated by step 2 of process.
24
    parser = OptionParser()
25
    scripts.db_options(parser)
26
    (options, args) = parser.parse_args()
27
    if args:
28
        parser.error("Too many arguments")
29
    scripts.execute_zcml_for_scripts(use_web_security=False)
30
13879.1.3 by William Grant
Drop now-obsolete connect(user) args.
31
    con = connect()
5799.1.59 by Stuart Bishop
Generate preamble for manual slonik usage.
32
    print '# slonik(1) preamble generated %s' % time.ctime()
5799.1.61 by Stuart Bishop
Review tweaks
33
    print '# LPCONFIG=%s' % config.instance_name
5799.1.59 by Stuart Bishop
Generate preamble for manual slonik usage.
34
    print
7675.85.2 by Jonathan Lange
Undo revision generated by step 2 of process.
35
    print replication.helpers.preamble(con)