cloudmesh.shell.shell

Module Contents

Classes

Plugin

Some simple methods to manage dynamic namespace plugins for cloudmesh.

CMShell

The command shell that inherits all commands from PluginCommand

Functions

iter_namespace(ns_pkg)

import_class(cl)

get_class(str)

main()

cms.

cloudmesh.shell.shell.iter_namespace(ns_pkg)
cloudmesh.shell.shell.import_class(cl)
cloudmesh.shell.shell.get_class(str)
class cloudmesh.shell.shell.Plugin

Bases: object

Some simple methods to manage dynamic namespace plugins for cloudmesh.

static list()
classmethod modules(cls)

list of cloudmesh modules in the cloudmesh namespace :return: list of modules

classmethod classes(cls)

list of the commands in the cloudmesh namespace under cloudmesh.command

Returns

list of the commands

classmethod name(cls, command)

creates a name for a modules starting with do_ :param command: returns a tuple with the module location and tge do_function :return:

classmethod class_name(cls, command)

creates the default filename in which the module is defined :param command: the name of the command :return: cloudmesh.ext.command.<command>+command.<Command>

classmethod load(cls, commands=None)
Parameters

commands

If None the commands will be found from import cloudmesh Otherwise the commands can be explicitly specified with

commands = [

‘cloudmesh.bar.command.bar.BarCommand’, ‘cloudmesh.foo.command.foo.FooCommand’, ]

A namespace package must exists. Foo and Bar ar just examples

Returns

the classes of the command

cloudmesh.shell.shell.selective_loading = True
cloudmesh.shell.shell.name
cloudmesh.shell.shell.PluginCommandClasses
class cloudmesh.shell.shell.CMShell(completekey='tab', stdin=None, stdout=None)

Bases: cmd.Cmd, PluginCommandClasses

The command shell that inherits all commands from PluginCommand

prompt = cms>
banner
do_q
set_debug(self, on)
do_commands(self, args, arguments)
Usage:

commands

precmd(self, line)

Hook method executed just before the command line is interpreted, but after the input prompt is generated and issued.

postcmd(self, stop, line)

Hook method executed just after a command dispatch is finished.

replace_vars(self, line)
onecmd(self, line)

Interpret the argument as though it had been typed in response to the prompt.

This may be overridden, but should not normally need to be; see the precmd() and postcmd() methods for useful execution hooks. The return value is a flag indicating whether interpretation of commands by the interpreter should stop.

do_py(self, args, arguments)
Usage:

py PROGRAM…

Arguments:

PROGRAM… the command to be executed

Description:

py PROGRAM… executes the command

do_shell(self, args, arguments)
Usage:

shell COMMAND

Arguments:

COMMAND the command to be executed

Description:

shell COMMAND executes the command

do_help(self, arg)
Usage:

help help COMMAND

Description:

List available commands with “help” or detailed help with “help COMMAND”.

In addition to the commands it also allows to print the api. The classes that help is available for can be listed with

cms info

help_help(self)
Usage:

help help COMMAND

Description:

List available commands with “help” or detailed help with “help COMMAND”.

do_info(self, args, arguments)
Usage:

info path info commands info files [errors] [–output=FORMAT] info cloudmesh info errors [–trace] info sys [KEYWORD] [–plugins] [–output=FORMAT] info

Options:
--format=FORMAT

the format to print the versions in [default: table]

Description:

info

provides internal info about the shell and its packages

The format option only works for

cms info files

preloop(self)

adds the banner to the preloop

do_EOF(self, args)
Usage:

EOF

Description:

Command to the shell to terminate reading a script.

do_quit(self, args)
Usage:

quit

Description:

Action to be performed when quit is typed

emptyline(self)

Called when an empty line is entered in response to the prompt.

If this method is not overridden, it repeats the last nonempty command entered.

do_version(self, args, arguments)
Usage:

version pip [PACKAGE] version [–format=FORMAT] [–check=CHECK] [–number]

Options:
--format=FORMAT

the format to print the versions in [default: table]

--check=CHECK

boolean tp conduct an additional check [default: True]

Description:
version

Prints out the version number

version pip

Prints the contents of pip list

Limitations:

Package names must not have a . in them instead you need to use - Thus to query for cloudmesh-cmd5 use

cms version pip cloudmesh-cmd5

cloudmesh.shell.shell.main()

cms.

Usage:

cms –help cms [–echo] [–debug] [–nosplash] [-i] [COMMAND …]

Arguments:

COMMAND A command to be executed

Options:
--file=SCRIPT
-f

SCRIPT Executes the script

-i

After start keep the shell interactive, otherwise quit [default: False]

--nosplash

do not show the banner [default: False]