1
2 """
3 load, quit, version, help plugins
4
5 Plugin read by omero.cli.Cli during initialization. The method(s)
6 defined here will be added to the Cli class for later use.
7
8 The load plugin is used to read in files with omero cli commands
9 (omitting the omero). For example,
10
11 ./omero load some/file.osh
12
13 The help, quit, and version plugins are self-explanatory.
14
15 Copyright 2008 Glencoe Software, Inc. All rights reserved.
16 Use is subject to license terms supplied in LICENSE.txt
17
18 """
19
20 import subprocess, optparse, os, sys
21 from omero.cli import Arguments, BaseControl, VERSION
22
24 - def help(self, args = None):
25 self.ctx.out("Run command with debug")
30
32 - def help(self, args = None):
33 self.ctx.out("Run command with tracing turned on")
35 args = Arguments(*args)
36 import trace
37 tracer = trace.Trace()
38 tracer.runfunc(self.ctx.pub, args)
39
41 - def help(self, args = None):
42 self.ctx.out("Run command with profiling")
43
45 args = Arguments(*args)
46 import hotshot
47 from hotshot import stats
48 prof = hotshot.Profile("hotshot_edi_stats")
49 rv = prof.runcall( lambda: self.ctx.pub(args) )
50 prof.close()
51 s = stats.load("hotshot_edi_stats")
52 s.sort_stats("time").print_stats()
53
55
56 - def help(self, args = None):
57 self.ctx.out("Quit application")
58
61
63
64 - def help(self, args = None):
65 self.ctx.out("Version number")
66
69
71
72 - def help(self = None):
73 status = "enabled"
74 try:
75 import readline
76 except:
77 status = "disabled"
78
79 self.ctx.out(
80 """
81 Syntax: %%(program_name)s file1 file2 file3
82
83 Load file as if it were sent on standard in. File tab-completion %s"
84 """ % status )
85
87 args = Arguments(*args)
88 for arg in args:
89 file = open(arg,'r')
90 self.ctx.dbg("Loading file %s" % arg)
91 for line in file:
92 self.pub.ctx(line)
93
95
96 - def help(self, args = None):
97 self.ctx.out("Starts an IPython interpreter session")
98
100 """
101 Copied from IPython embed-short example
102 """
103 args = Arguments(*args)
104 from IPython.Shell import IPShellEmbed
105 ipshell = IPShellEmbed(args.args)
106 ipshell()
107
108 try:
109 register("load", LoadControl)
110 register("quit", QuitControl)
111 register("shell", ShellControl)
112 register("version", VersionControl)
113 register("debug", DebugControl)
114 register("profile", ProfileControl)
115 register("trace", TraceControl)
116 except NameError:
117 VersionControl()._main()
118