Package omero :: Package plugins :: Module perf
[hide private]
[frames] | no frames]

Source Code for Module omero.plugins.perf

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3  """ 
 4     Plugin for measuring the performance of an OMERO 
 5     installation. 
 6   
 7     Plugin read by omero.cli.Cli during initialization. The method(s) 
 8     defined here will be added to the Cli class for later use. 
 9   
10     Copyright 2008 Glencoe Software, Inc. All rights reserved. 
11     Use is subject to license terms supplied in LICENSE.txt 
12   
13  """ 
14   
15  import sys 
16  from omero.cli import BaseControl, CLI 
17  from omero_ext.argparse import FileType 
18  import omero.install.perf_test as perf_test 
19   
20  HELP = """Run perf_test files 
21   
22  %s 
23   
24  """ % perf_test.FILE_FORMAT 
25   
26   
27 -class PerfControl(BaseControl):
28
29 - def _configure(self, parser):
30 parser.add_argument( 31 "-l", "--list", action="store_true", 32 help="List available commands") 33 parser.add_argument( 34 "file", nargs="*", type=FileType('r'), default=None, 35 help="Read from files or standard in") 36 parser.set_defaults(func=self.__call__) 37 parser.add_login_arguments()
38
39 - def __call__(self, args):
40 if args.list: 41 ops = [x[4:] for x in dir(perf_test.Item) if x.startswith("_op_")] 42 ops.sort() 43 for op in ops: 44 print op 45 else: 46 if not args.file: 47 self.ctx.die(167, "No files given. Use '-' for stdin.") 48 client = self.ctx.conn(args) 49 ctx = perf_test.Context(None, client=client) 50 self.ctx.out("Saving performance results to %s" % ctx.dir) 51 ctx.add_reporter(perf_test.CsvReporter(ctx.dir)) 52 # ctx.add_reporter(perf_test.HdfReporter(ctx.dir)) 53 # ctx.add_reporter(perf_test.PlotReporter()) 54 handler = perf_test.PerfHandler(ctx) 55 perf_test.handle(handler, args.file)
56 57 try: 58 register("perf", PerfControl, HELP) 59 except NameError: 60 if __name__ == "__main__": 61 cli = CLI() 62 cli.register("perf", PerfControl, HELP) 63 cli.invoke(sys.argv[1:]) 64