~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to utilities/report-database-stats.py

  • Committer: Stuart Bishop
  • Date: 2011-09-28 12:49:24 UTC
  • mfrom: (9893.10.1 trivial)
  • mto: This revision was merged to the branch mainline in revision 14178.
  • Revision ID: stuart.bishop@canonical.com-20110928124924-m5a22fymqghw6c5i
Merged trivial into distinct-db-users.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python -S
2
 
# Copyright 2010 Canonical Ltd.  This software is licensed under the
 
2
# Copyright 2010-2011 Canonical Ltd.  This software is licensed under the
3
3
# GNU Affero General Public License version 3 (see the file LICENSE).
4
4
 
5
5
"""Generate the database statistics report."""
6
6
 
7
7
__metaclass__ = type
8
8
 
9
 
import _pythonpath
10
 
 
11
9
from datetime import datetime
12
10
from operator import attrgetter
13
11
from textwrap import (
15
13
    fill,
16
14
    )
17
15
 
18
 
from canonical.database.sqlbase import connect, sqlvalues
 
16
import _pythonpath
 
17
 
 
18
from canonical.database.sqlbase import (
 
19
    connect,
 
20
    sqlvalues,
 
21
    )
19
22
from canonical.launchpad.scripts import db_options
20
23
from lp.scripts.helpers import LPOptionParser
21
24
from lp.services.database.namedrow import named_fetchall
229
232
    parser.add_option(
230
233
        "-i", "--interval", dest="interval", type=str,
231
234
        default=None, metavar="INTERVAL",
232
 
        help=
 
235
        help=(
233
236
            "Use statistics collected over the last INTERVAL period. "
234
237
            "INTERVAL is a string parsable by PostgreSQL "
235
 
            "such as '5 minutes'.")
 
238
            "such as '5 minutes'."))
236
239
    parser.add_option(
237
240
        "-n", "--limit", dest="limit", type=int,
238
241
        default=15, metavar="NUM",