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

Class CLI

source code


Command line interface class. Supports various styles of executing the registered plugins. Each plugin is given the chance to update this class by adding methods of the form "do_<plugin name>".

Nested Classes [hide private]
  PluginsLoaded
Thread-safe class for storing whether or not all the plugins have been loaded
Instance Methods [hide private]
 
__init__(self, prog=sys.argv [0])
Also sets the "_client" field for this instance to None.
source code
 
assertRC(self) source code
 
invoke(self, line, strict=False, previous_args=None)
Copied from cmd.py
source code
 
invokeloop(self) source code
 
postloop(self)
Hook method executed once when the cmdloop() method is about to return.
source code
 
onecmd(self, line, previous_args=None)
Single command logic.
source code
 
postcmd(self, stop, line)
Checks interrupt_loop for True and return as much which will end the call to cmdloop.
source code
 
execute(self, line, previous_args)
String/list handling as well as EOF and comment handling.
source code
 
completedefault(self, *args)
Method called to complete an input line when no command-specific complete_*() method is available.
source code
 
completenames(self, text, line, begidx, endidx) source code
 
exit(self, args, newline=True) source code
 
die(self, rc, text, newline=True) source code
 
_env(self)
Configure environment with PYTHONPATH as setup by bin/omero
source code
 
_cwd(self, cwd) source code
 
call(self, args, strict=True, cwd=None)
Calls the string in a subprocess and dies if the return value is not 0
source code
 
popen(self, args, cwd=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) source code
 
readDefaults(self) source code
 
parsePropertyFile(self, data, output) source code
 
initData(self, properties=None)
Uses "omero prefs" to create an Ice.InitializationData().
source code
 
conn(self, args=None)
Returns any active _client object.
source code
 
close(self) source code
 
register(self, name, Control, help) source code
 
register_only(self, name, Control, help)
This method is added to the globals when execfile() is called on each plugin.
source code
 
configure_plugins(self)
Run to instantiate and configure all plugins which were registered via register_only()
source code
 
waitForPlugins(self) source code
 
loadplugins(self)
Finds all plugins and gives them a chance to register themselves with the CLI instance.
source code
 
loadpath(self, pathobj) source code

Inherited from cmd.Cmd: cmdloop, columnize, complete, complete_help, default, do_help, emptyline, get_names, parseline, precmd, preloop, print_topics

Inherited from Context: add_login, dbg, err, get, input, out, parser_init, post_process, pub, pythonpath, safePrint, set, sleep, userdir

Class Variables [hide private]

Inherited from cmd.Cmd: doc_header, doc_leader, identchars, intro, lastcmd, misc_header, nohelp, prompt, ruler, undoc_header, use_rawinput

Instance Variables [hide private]
  rv
Return value to be returned
  _stack
List of commands being processed
  _client
Single client for all activities
  _plugin_paths
Paths to be loaded; initially official plugins
Method Details [hide private]

__init__(self, prog=sys.argv [0])
(Constructor)

source code 

Also sets the "_client" field for this instance to None. Each cli maintains a single active client. The "session" plugin is responsible for the loading of the client object.

Overrides: Context.__init__

postloop(self)

source code 

Hook method executed once when the cmdloop() method is about to return.

Overrides: cmd.Cmd.postloop
(inherited documentation)

onecmd(self, line, previous_args=None)

source code 

Single command logic. Overrides the cmd.Cmd logic by calling execute. Also handles various exception conditions.

Overrides: cmd.Cmd.onecmd

postcmd(self, stop, line)

source code 

Checks interrupt_loop for True and return as much which will end the call to cmdloop. Otherwise use the default postcmd logic (which simply returns stop)

Overrides: cmd.Cmd.postcmd

execute(self, line, previous_args)

source code 

String/list handling as well as EOF and comment handling. Otherwise, parses the arguments as shlexed and runs the function returned by argparse.

completedefault(self, *args)

source code 

Method called to complete an input line when no command-specific complete_*() method is available.

By default, it returns an empty list.

Overrides: cmd.Cmd.completedefault
(inherited documentation)

completenames(self, text, line, begidx, endidx)

source code 
Overrides: cmd.Cmd.completenames

exit(self, args, newline=True)

source code 
Overrides: Context.exit

die(self, rc, text, newline=True)

source code 
Overrides: Context.die

_env(self)

source code 

Configure environment with PYTHONPATH as setup by bin/omero

This list needs to be kept in line with OmeroPy/bin/omero

call(self, args, strict=True, cwd=None)

source code 

Calls the string in a subprocess and dies if the return value is not 0

Overrides: Context.call

popen(self, args, cwd=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)

source code 
Overrides: Context.popen

conn(self, args=None)

source code 

Returns any active _client object. If one is present but not alive, it will be removed.

If no client is found and arguments are available, will use the current settings to connect.

If required attributes are missing, will delegate to the login command.

FIXME: Currently differing setting sessions on the same CLI instance will misuse a client.

register_only(self, name, Control, help)

source code 

This method is added to the globals when execfile() is called on each plugin. A Control class should be passed to the register method which will be added to the CLI.

loadplugins(self)

source code 

Finds all plugins and gives them a chance to register themselves with the CLI instance. Here register_only() is used to guarantee the orderedness of the plugins in the parser