~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
#
3
# Copyright 2009 Canonical Ltd.  This software is licensed under the
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
12
import _pythonpath
13
14
import time
7675.85.2 by Jonathan Lange
Undo revision generated by step 2 of process.
15
from optparse import OptionParser
5799.1.59 by Stuart Bishop
Generate preamble for manual slonik usage.
16
5799.1.61 by Stuart Bishop
Review tweaks
17
from canonical.config import config
7675.85.2 by Jonathan Lange
Undo revision generated by step 2 of process.
18
from canonical.database.sqlbase import connect
19
from canonical.launchpad import scripts
20
5799.1.59 by Stuart Bishop
Generate preamble for manual slonik usage.
21
import replication.helpers
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
31
    con = connect(options.dbuser)
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)
5799.1.59 by Stuart Bishop
Generate preamble for manual slonik usage.
36