cmd Package

base Module

class opennode.oms.endpoint.ssh.cmd.base.Cmd(protocol)[source]

Bases: object

arg_parser(*args, **kwargs)[source]

Returns the argument parser for this command.

Use partial=True if you want to tolerate incomplete last token and avoid executing help action (e.g. during completion).

contextual_arg_parser(*args, **kwargs)[source]

If command offers a contextual parser, use it, otherwise fall back to a normal parser.

current_obj[source]
execute(args)[source]

Subclasses should override this if they need parsed arguments.

obj_path[source]
parse_args(*args, **kwargs)[source]

Parse command line arguments. Return a deferred.

path[source]

Current working directory

register(*args, **kwargs)[source]
subject(args)[source]

Provide the subject of the command (usually free arguments and/or current directory path)

subject_from_raw(*args, **kwargs)[source]

Subclasses should override this if they need raw arguments.

traverse(path)[source]
traverse_full(path)[source]
unregister()[source]
write(*args)[source]

Ensure that all writes are serialized regardless if the command is executing in another thread.

class opennode.oms.endpoint.ssh.cmd.base.CommandContextExtractor(context)[source]

Bases: grokcore.component.components.Subscription

get_context()[source]

commands Module

class opennode.oms.endpoint.ssh.cmd.commands.CatLogCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

arguments()[source]
execute(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.CatObjectCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

arguments()[source]
execute(*args, **kwargs)[source]
subject(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.ChangeDirCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

arguments()[source]
execute(*args, **kwargs)[source]
subject(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.CommonArgs(context)[source]

Bases: grokcore.component.components.Subscription

Just an example of common args, not actually sure that -v is needed in every command.

arguments()[source]
class opennode.oms.endpoint.ssh.cmd.commands.CreateObjCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

arguments(*args, **kwargs)[source]
execute(*args, **kwargs)[source]
subject(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.EchoCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Outputs the command line arguments.

arguments()[source]
execute(args)[source]
class opennode.oms.endpoint.ssh.cmd.commands.EditCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

arguments()[source]
execute(*args, **kwargs)[source]
subject(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.FileCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Outputs the type of an object.

arguments()[source]
execute(*args, **kwargs)[source]
subject(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.HelpCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Outputs the names of all commands.

arguments(*args, **kwargs)[source]
execute(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.HistoryCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Prints the shell history.

execute(args)[source]
class opennode.oms.endpoint.ssh.cmd.commands.IdCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

arguments()[source]
execute(args)[source]
subject(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.KillTaskCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Implement the kill command which can send signals to tasks.

arguments()[source]
execute(args)[source]
find_task(tid)[source]
class opennode.oms.endpoint.ssh.cmd.commands.LastErrorCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Prints out the last error.

Useful for devs, and users reporting to issue tracker. (Inspired by xsbt)

execute(args)[source]
class opennode.oms.endpoint.ssh.cmd.commands.LinkCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Creates a (sym)link to an object.

arguments()[source]
execute(*args, **kwargs)[source]
subject(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.ListDirContentsCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

arguments()[source]
execute(*args, **kwargs)[source]
subject(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.MoveCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Moves an object.

arguments()[source]
execute(*args, **kwargs)[source]
subject(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.NoCommand(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Represents the fact that there is no command yet.

class opennode.oms.endpoint.ssh.cmd.commands.OmsShellCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

This command represents the oms shell. Currently it cannot run a nested shell.

execute(args)[source]
class opennode.oms.endpoint.ssh.cmd.commands.PrintEnvCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Prints the environment variables.

execute(args)[source]
class opennode.oms.endpoint.ssh.cmd.commands.PrintWorkDirCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

execute(args)[source]
class opennode.oms.endpoint.ssh.cmd.commands.QuitCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Quits the console.

execute(args)[source]
class opennode.oms.endpoint.ssh.cmd.commands.RemoveCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Deletes an object.

arguments()[source]
execute(*args, **kwargs)[source]
subject(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.SetAttrCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

arguments()[source]
execute(*args, **kwargs)[source]
subject(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.SetEnvCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Modifies the environment variables.

arguments()[source]
execute(args)[source]
class opennode.oms.endpoint.ssh.cmd.commands.SetOrMkCmdDynamicArguments(context)[source]

Bases: grokcore.component.components.Adapter

Dynamically creates the key=value arguments for the set and mk commands depending on the object or type being edited or created.

arguments(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.SleepCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Do nothing for some time.

arguments()[source]
execute(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.TaskListCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Emulates ‘ps’ command, including bsd args.

arguments()[source]
execute(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.commands.TerminalResetCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

Resets terminal. Useful after interrupting an attach.

arguments()[source]
execute(args)[source]

completers Module

class opennode.oms.endpoint.ssh.cmd.completers.ArgSwitchCompleter(context)[source]

Bases: opennode.oms.endpoint.ssh.cmd.completion.Completer

Completes argument switches based on the argparse grammar exposed for a command

complete(token, parsed, parser, **kwargs)[source]
option_consumed(action, parsed)[source]
class opennode.oms.endpoint.ssh.cmd.completers.CommandCompleter(context)[source]

Bases: opennode.oms.endpoint.ssh.cmd.completers.PathCompleter

Completes a command.

complete(*args, **kwargs)[source]
expected_action(parsed, parser)[source]
class opennode.oms.endpoint.ssh.cmd.completers.EnvironmentCompleter(context)[source]

Bases: opennode.oms.endpoint.ssh.cmd.completion.Completer

complete(token, parsed, parser, protocol=None, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.completers.KeywordPathSubCompleter(context, base_path='')[source]

Bases: opennode.oms.endpoint.ssh.cmd.completers.PathCompleter

Implement a FS path completer which works as subcompleter for the keyworded arguments.

complete(*args, **kwargs)[source]
expected_action(parsed, parser)[source]
traverse(path)[source]
class opennode.oms.endpoint.ssh.cmd.completers.KeywordSwitchCompleter(context)[source]

Bases: opennode.oms.endpoint.ssh.cmd.completers.ArgSwitchCompleter

Completes key=value argument switches based on the argparse grammar exposed for a command. TODO: probably more can be shared with ArgSwitchCompleter.

complete(token, parsed, parser, display=False, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.completers.KeywordValueCompleter(context)[source]

Bases: opennode.oms.endpoint.ssh.cmd.completers.ArgSwitchCompleter

Completes the value part of key=value constructs based on the type of the keyword. Currently works only for args which declare an explicit enumeration.

complete(token, parsed, parser, **kwargs)[source]
find_action(keyword, parsed, parser)[source]
class opennode.oms.endpoint.ssh.cmd.completers.PathCompleter(context)[source]

Bases: opennode.oms.endpoint.ssh.cmd.completers.PositionalCompleter

Completes a path name.

complete(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.completers.PositionalChoiceCompleter(context)[source]

Bases: opennode.oms.endpoint.ssh.cmd.completers.PositionalCompleter

complete(token, parsed, parser, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.completers.PositionalCompleter(context)[source]

Bases: opennode.oms.endpoint.ssh.cmd.completion.Completer

Base class for positional completers.

expected_action(parsed, parser)[source]

Currently expected action. It looks at the cardinalities

completion Module

class opennode.oms.endpoint.ssh.cmd.completion.Completer(context)[source]

Bases: grokcore.component.components.Subscription

opennode.oms.endpoint.ssh.cmd.completion.complete(*args, **kwargs)[source]

Bash like dummy completion, not great like zsh completion. Problems: completion in the middle of a word will screw it (like bash)

directives Module

class opennode.oms.endpoint.ssh.cmd.directives.command(*args, **kw)[source]

Bases: martian.directive.Directive

Use this directive in a class in order to set its command name. Only classes marked with this directive will be valid commands.

default = None
scope = <martian.directive.ClassScope object at 0x2821cd0>
store = <martian.directive.StoreOnce object at 0x2821910>
class opennode.oms.endpoint.ssh.cmd.directives.alias(*args, **kw)[source]

Bases: martian.directive.Directive

Use this directive in a class in order to add an alias. TODO: make it work with multiple aliases.

default = None
scope = <martian.directive.ClassScope object at 0x2821cd0>
store = <martian.directive.StoreOnce object at 0x2821910>

grokkers Module

class opennode.oms.endpoint.ssh.cmd.grokkers.AliasGrokker[source]

Bases: martian.components.ClassGrokker

execute(class_, alias, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.grokkers.CmdGrokker[source]

Bases: martian.components.ClassGrokker

execute(class_, command, **kw)[source]

registry Module

opennode.oms.endpoint.ssh.cmd.registry.commands()[source]

A map of command names to command objects.

opennode.oms.endpoint.ssh.cmd.registry.get_command(name)[source]

Returns the command class for a given name.

Returns NoCommand if the name is empty. Returns UnknownCommand if the command does not exist.

security Module

class opennode.oms.endpoint.ssh.cmd.security.GetAclCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

arguments()[source]
execute(*args, **kwargs)[source]
exception opennode.oms.endpoint.ssh.cmd.security.NoSuchPermission[source]

Bases: exceptions.Exception

class opennode.oms.endpoint.ssh.cmd.security.PermCheckCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

arguments()[source]
check_rights(obj, args)[source]
execute(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.security.SetAclCmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

arguments()[source]
execute(*args, **kwargs)[source]
class opennode.oms.endpoint.ssh.cmd.security.WhoAmICmd(protocol)[source]

Bases: opennode.oms.endpoint.ssh.cmd.base.Cmd

execute(args)[source]
opennode.oms.endpoint.ssh.cmd.security.effective_perms(interaction, obj)[source]
opennode.oms.endpoint.ssh.cmd.security.pretty_effective_perms(interaction, obj)[source]