Package omero :: Module cli :: Class BaseControl
[hide private]
[frames] | no frames]

Class BaseControl

source code

Controls get registered with a CLI instance on loadplugins().

To create a new control, subclass BaseControl and end your module with:

   try:
       registry("name", MyControl)
   except:
       MyControl()._main()

This module should be put in the omero.plugins package.

All methods which do NOT begin with "_" are assumed to be accessible to CLI users.

Instance Methods [hide private]
 
__init__(self, ctx=Context(), dir=OMERODIR) source code
 
_isWindows(self) source code
 
_host(self)
Return hostname of current machine.
source code
 
_node(self, omero_node=None)
Return the name of this node, using either the environment vairable OMERO_NODE or _host().
source code
 
_icedata(self, property)
General data method for creating a path from an Ice property.
source code
 
_initDir(self)
Initialize the directory into which the current node will log.
source code
 
_nodedata(self)
Returns the data directory path for this node.
source code
 
_regdata(self)
Returns the data directory for the IceGrid registry.
source code
 
_pid(self)
Returns a path of the form "_nodedata() / _node() + ".pid", i.e.
source code
 
_cfglist(self)
Returns a list of configuration files for this node.
source code
 
_icecfg(self)
Uses _cfglist() to return a string argument of the form "--Ice.Config=..." suitable for passing to omero.client as an argument.
source code
 
_intcfg(self)
Returns an Ice.Config string with only the internal configuration file for connecting to the IceGrid Locator.
source code
 
_properties(self, prefix="")
Loads all files returned by _cfglist() into a new Ice.Properties instance and return the map from getPropertiesForPrefix(prefix) where the default is to return all properties.
source code
 
_ask_for_password(self, reason="", root_pass=None) source code
 
help(self, args=[]) source code
 
_complete(self, text, line, begidx, endidx) source code
 
_likes(self, args)
Checks whether or not it is likely for the given args to be run successfully by the given command.
source code
 
__call__(self, *args)
Main dispatch method for a control instance.
source code
 
_noargs(self)
Method called when __call__() is called without any arguments.
source code
 
_main(self)
Simple _main() logic which is reusable by subclasses to do something when the control is executed directly.
source code
Method Details [hide private]

_host(self)

source code 

Return hostname of current machine. Termed to be the value return from socket.gethostname() up to the first decimal.

_node(self, omero_node=None)

source code 

Return the name of this node, using either the environment vairable OMERO_NODE or _host(). Some subclasses may override this functionality, most notably "admin" commands which assume a node name of "master".

If the optional argument is not None, then the OMERO_NODE environment variable will be set.

_nodedata(self)

source code 

Returns the data directory path for this node. This is determined from the "IceGrid.Node.Data" property in the _properties() map.

The directory will be created if it does not exist.

_regdata(self)

source code 

Returns the data directory for the IceGrid registry. This is determined from the "IceGrid.Registry.Data" property in the _properties() map.

The directory will be created if it does not exist, and a warning issued.

_pid(self)

source code 

Returns a path of the form "_nodedata() / _node() + ".pid", i.e. a file named NODENAME.pid in the node's data directory.

_cfglist(self)

source code 

Returns a list of configuration files for this node. This defaults to the internal configuration for all nodes, followed by a file named NODENAME.cfg under the etc/ directory, following by PLATFORM.cfg if it exists.

_likes(self, args)

source code 

Checks whether or not it is likely for the given args to be run successfully by the given command. This is useful for plugins which have significant start up times.

Simply return True is a possible solution. The default implementation checks that the subclass has a method matching the first argument, such that the default __call__() implementation could dispatch to it. Or if no arguments are given, True is returned since self._noargs() can be called.

__call__(self, *args)
(Call operator)

source code 

Main dispatch method for a control instance. The default implementation assumes that the *args consists of either no elements or exactly one list of strings ==> (["str"],)

If no args are present, _noargs is called. Subclasses may want to read from stdin or drop into a shell from _noargs().

Otherwise, the rest of the arguments are passed to the method named by the first argument, if _likes() returns True.

_noargs(self)

source code 

Method called when __call__() is called without any arguments. Some implementations may want to drop the user into a shell or read from standard in. By default, help() is printed.

_main(self)

source code 

Simple _main() logic which is reusable by subclasses to do something when the control is executed directly. It is unlikely that such an excution will function properly, but it may be useful for testing purposes.