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

Class Context

source code

Simple context used for default logic. The CLI registry which registers the plugins installs itself as a fully functional Context.

The Context class is designed to increase pluggability. Rather than making calls directly on other plugins directly, the pub() method routes messages to other commands. Similarly, out() and err() should be used for printing statements to the user, and die() should be used for exiting fatally.

Instance Methods [hide private]
 
__init__(self, controls={}, params={}) source code
 
post_process(self)
Runs further processing once all the controls have been added.
source code
 
add_login(self, parser) source code
 
parser_init(self, parser) source code
 
get(self, key, defvalue=None) source code
 
set(self, key, value=True) source code
 
safePrint(self, text, stream, newline=True)
Prints text to a given string, caputring any exceptions.
source code
 
pythonpath(self)
Converts the current sys.path to a PYTHONPATH string to be used by plugins which must start a new process.
source code
 
userdir(self)
Returns a user directory (as path.path) which can be used for storing configuration.
source code
 
pub(self, args, strict=False) source code
 
input(self, prompt, hidden=False, required=False)
Reads from standard in.
source code
 
out(self, text, newline=True)
Expects as single string as argument"
source code
 
err(self, text, newline=True)
Expects a single string as argument.
source code
 
dbg(self, text, newline=True, level=1)
Passes text to err() if self.isdebug is set
source code
 
die(self, rc, args) source code
 
exit(self, args) source code
 
call(self, args) source code
 
popen(self, args) source code
 
sleep(self, time) source code
Method Details [hide private]

pythonpath(self)

source code 

Converts the current sys.path to a PYTHONPATH string to be used by plugins which must start a new process.

Note: this was initially created for running during testing when PYTHONPATH is not properly set.

userdir(self)

source code 

Returns a user directory (as path.path) which can be used for storing configuration. The directory is guaranteed to exist and be private (700) after execution.

input(self, prompt, hidden=False, required=False)

source code 

Reads from standard in. If hidden == True, then uses getpass