Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
clearpath.horizon.cli.HorizonDemo Class Reference

Basic Command-Line Controller. More...

List of all members.

Public Member Functions

def __del__
 Destroy a Horizon Demo.
def __init__
 Create A Horizon Command-Line Controller.
def complete_repeat
 Repeat Command Tab Completion.
def complete_subscribe
 Subscribe Command Tab Completion.
def do_about
 About Horizon Device.
def do_EOF
 Exit the Interactive Shell.
def do_exit
 Exit the Interactive Shell.
def do_get_time
 Horizon Device Time.
def do_help
 List all Commands.
def do_is_alive
 Horizon Device Alive?
def do_quit
 Exit the Interactive Shell.
def do_repeat
 Manipulate repeated commands.
def do_subscribe
 Subscribe to Command.
def emptyline
 Empty Line Action.

Public Attributes

 doc_leader
 intro
 prompt

Private Member Functions

def _about
 Get Horizon About String.
def _arguments_to_values
 Convert Arguments to their Proper Types.
def _extract_arguments
 Extract Arguments.
def _handler
 Output Subscription Data.
def _list_repeats
 List active repeat commands.
def _parse_arguments
 Parse a Line of Arguments.
def _print_help
 Prints a usage message for a command.
def _remove_repeat
 Remove an active repeat command.
def _repeat
 Command Repeater Loop.
def _setup_repeat
 Subscribe to repeat a command at a specified interval.
def _waiting
 Get Waiting Data.
def _waiting_complete
 Get Waiting Command Tab Completion.

Private Attributes

 _cmd_lock
 _commands
 Repetition Commands.
 _horizon
 Horizon Interface.
 _output
 Subscription Output.
 _repeater
 Repeat Thread.
 _repeating
 Repeat Looping?

Detailed Description

Basic Command-Line Controller.

Horizon Command-Line Controller

Interactive shell for controlling a Horizon device.

See also:
cmd.Cmd
Since:
0.1
Horizon Command-Line Controller

Definition at line 239 of file horizon/cli.py.


Constructor & Destructor Documentation

def clearpath.horizon.cli.HorizonDemo.__init__ (   self,
  port,
  horizon,
  output = '' 
)

Create A Horizon Command-Line Controller.

Parameters:
portThe device name to use in the prompt ('horizon:port$')
horizonThe Horizon instance to send commands to. Must already be opened.
outputWhere to send subscription data? '' and '/dev/null' indicates nowhere and enables 'get_waiting'
Create A Horizon Command-Line Controller

Definition at line 253 of file horizon/cli.py.

Destroy a Horizon Demo.

Horizon Demo class destructor.
Stops the repeat thread if running.

Destroy a Horizon Demo.

Definition at line 342 of file horizon/cli.py.


Member Function Documentation

def clearpath.horizon.cli.HorizonDemo._about (   self) [private]

Get Horizon About String.

Returns:
string of Horizon information
Get Horizon About String

Definition at line 359 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo._arguments_to_values (   self,
  params,
  method 
) [private]

Convert Arguments to their Proper Types.

Converts arguments based on given default values.
Prints argument errors to stdout.

Parameters:
paramsThe arguments to convert
methodThe method to convert for
Returns:
Dictionary of values, Empty if none, None if error encountered
Convert arguments to their proper types.

Definition at line 514 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo._extract_arguments (   self,
  arguments 
) [private]

Extract Arguments.

Extract arguments from a Line using whitespace as separators.

Parameters:
argumentsThe line to extract from
Returns:
List of string arguments, empty if none
Extract arguments from a Line.

Definition at line 457 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo._handler (   self,
  payload 
) [private]

Output Subscription Data.

Writes subscription data to the output file.

Parameters:
payloadThe received payload
Output Subscription Data

Definition at line 742 of file horizon/cli.py.

List active repeat commands.

Definition at line 1279 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo._parse_arguments (   self,
  method,
  arguments 
) [private]

Parse a Line of Arguments.

Extracts arguments from a line for the given method.
Runs the method.
Outputs anything that is returned.
ValueErrors are treated as command argument errors.

Parameters:
methodThe method to execute
argumentsThe string containing the whitespace separated arguments
Parse a Line of Arguments

Definition at line 678 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo._print_help (   self,
  method 
) [private]

Prints a usage message for a command.

Definition at line 711 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo._remove_repeat (   self,
  arguments 
) [private]

Remove an active repeat command.

Parameters:
argumentsCommand line arguments after 'repeat', assumed to be stripped.

Definition at line 1299 of file horizon/cli.py.

Command Repeater Loop.

Repeater Thread method. Loops on _repeating waiting to send commands.

Command Repeater Loop

Definition at line 772 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo._setup_repeat (   self,
  arguments 
) [private]

Subscribe to repeat a command at a specified interval.

Parameters:
argumentsLine entered after 'repeat'

Definition at line 1334 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo._waiting (   self,
  line 
) [private]

Get Waiting Data.

Outputs data retrieved from subscriptions.

Parameters:
lineThe rest of the line
syntax: get_waiting [<request>]\n

Definition at line 828 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo._waiting_complete (   self,
  text,
  line,
  begidx,
  endidx 
) [private]

Get Waiting Command Tab Completion.

Calculates a list of possible paramters for get_waiting based on the entered prefix.

Parameters:
textThe last parameter before tab
lineThe entire line of text
begidx???
endidx???
Returns:
List of string possibilities
Get Waiting Command Tab Completion

Definition at line 908 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo.complete_repeat (   self,
  text,
  line,
  begidx,
  endidx 
)

Repeat Command Tab Completion.

Calculates a list of possible paramters for repeat based on the entered prefix.

Parameters:
textThe last parameter before tab
lineThe entire line of text
begidx??? - Passed on to other functions
endidx??? - Passed on to other functions
Returns:
List of string possibilities
Repeat Command Tab Completion

Definition at line 1424 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo.complete_subscribe (   self,
  text,
  line,
  begidx,
  endidx 
)

Subscribe Command Tab Completion.

Calculates a list of possible paramters for subscribe based on the entered prefix.

Parameters:
textThe last parameter before tab
lineThe entire line of text
begidx??? - Passed on to other functions
endidx??? - Passed on to other functions
Returns:
List of string possibilities
Subscribe Command Tab Completion

Definition at line 1195 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo.do_about (   self,
  arguments 
)

About Horizon Device.

Get information on the Horizon device.

Parameters:
argumentsLine entered after 'about'
syntax: about \n

Definition at line 1003 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo.do_EOF (   self,
  arg 
)

Exit the Interactive Shell.

Stop the command loop

Parameters:
selfThis object
argLine entered after 'exit'
Returns:
True Forces end of loop
syntax: ^d

Definition at line 1526 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo.do_exit (   self,
  arg 
)

Exit the Interactive Shell.

Stop the command loop

Parameters:
selfThis object
argLine entered after 'exit'
Returns:
True Forces end of loop
syntax: exit

Definition at line 1509 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo.do_get_time (   self,
  arguments 
)

Horizon Device Time.

Get the Horizon device time.

Parameters:
argumentsLine entered after 'get_time'
syntax: get_time \n

Definition at line 1049 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo.do_help (   self,
  arg 
)

List all Commands.

Overrides Cmd default to categorize Horizon messages.

See also:
Cmd.do_help
syntax: help [<command>]\n

Definition at line 945 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo.do_is_alive (   self,
  arguments 
)

Horizon Device Alive?

Check if the Horizon device is alive.

Parameters:
argumentsLine entered after 'about'
syntax: is_alive \n

Definition at line 1026 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo.do_quit (   self,
  arg 
)

Exit the Interactive Shell.

Stop the command loop

Parameters:
selfThis object
argLine entered after 'exit'
Returns:
True Forces end of loop
syntax: quit

Definition at line 1492 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo.do_repeat (   self,
  arguments 
)

Manipulate repeated commands.

Parameters:
argumentsLine entered after 'repeat'
usage: repeat [list | off [n] | [frequency command]]\n\n

Definition at line 1259 of file horizon/cli.py.

def clearpath.horizon.cli.HorizonDemo.do_subscribe (   self,
  arguments 
)

Subscribe to Command.

Subscribe to receive request data at a specified interval.

Parameters:
argumentsLine entered after 'subscribe'
syntax: subscribe <frequency> <command>\n

Definition at line 1102 of file horizon/cli.py.

Empty Line Action.

Does nothing when an empty line is entered rather than the default 'repeat last command'.

Empty Line Action

Definition at line 932 of file horizon/cli.py.


Member Data Documentation

Definition at line 254 of file horizon/cli.py.

Repetition Commands.

Definition at line 254 of file horizon/cli.py.

Horizon Interface.

Definition at line 255 of file horizon/cli.py.

Subscription Output.

Definition at line 256 of file horizon/cli.py.

Repeat Thread.

Definition at line 257 of file horizon/cli.py.

Repeat Looping?

Definition at line 258 of file horizon/cli.py.

Definition at line 258 of file horizon/cli.py.

Definition at line 258 of file horizon/cli.py.

Definition at line 258 of file horizon/cli.py.


The documentation for this class was generated from the following file:


clearpath_base
Author(s): Mike Purvis
autogenerated on Sun Oct 5 2014 22:52:08