File: runalyzer

package info (click to toggle)
pytools 10-7
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 404 kB
  • ctags: 796
  • sloc: python: 4,175; makefile: 9
file content (40 lines) | stat: -rw-r--r-- 1,126 bytes parent folder | download
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
#! /usr/bin/env python




# main program ----------------------------------------------------------------
def main():
    import sys
    from optparse import OptionParser

    parser = OptionParser(usage="%prog DBFILE [SCRIPT]")
    parser.add_option("-m", "--mangle", action="store_true",
            help="whether to try and mangle SQL queries")
    options, args = parser.parse_args()

    if len(args) not in [1, 2]:
        parser.print_help()
        sys.exit(1)

    sys.path.append(".")

    from pytools.runalyzer import make_wrapped_db

    if len(args) == 2:
        db = make_wrapped_db(args[0], mangle=options.mangle, interactive=False)
        symbols = {"db": db}
        execfile(args[1], symbols)
    else:
        db = make_wrapped_db(args[0], mangle=options.mangle, interactive=True)
        from pytools.runalyzer import RunalyzerConsole
        cons = RunalyzerConsole(db)
        cons.interact("Runalyzer running on Python %s\n"
                "Copyright (c) Andreas Kloeckner 2008\n" 
                "Run .help to see help for magic commands" % sys.version)




if __name__ == "__main__":
    main()