moler.cmd.unix package

Submodules

moler.cmd.unix.bash module

Bash command module.

class moler.cmd.unix.bash.Bash(connection, prompt=None, newline_chars=None, runner=None, bash='TERM=xterm-mono bash')

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()
Returns:String representation of command to send over connection to device.

moler.cmd.unix.cat module

Cat command module.

class moler.cmd.unix.cat.Cat(connection, path, options=None, prompt=None, newline_chars=None, runner=None, failure_only_in_first_line=True)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds string with command.

Returns:String with command.
is_failure_indication(line)

Method to detect if passed line contains part indicating failure of command.

Parameters:line – Line from command output on device
Returns:Match object if find regex in line, None otherwise.
on_new_line(line, is_full_line)

Parses the output of the command.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

set_exception(exception)

Set exception object as failure for command object.

Parameters:exception – An exception object to set.
Returns:None.

moler.cmd.unix.cd module

cd command module.

class moler.cmd.unix.cd.Cd(connection, path=None, prompt=None, newline_chars=None, runner=None, expected_prompt=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.chgrp module

Chgrp command module.

class moler.cmd.unix.chgrp.Chgrp(connection, files, group, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.chmod module

chmod command module.

class moler.cmd.unix.chmod.Chmod(connection, permission, filename, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.chown module

chown command module.

class moler.cmd.unix.chown.Chown(connection, param, filename, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.cp module

Cp command module.

class moler.cmd.unix.cp.Cp(connection, src, dst, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.ctrl_c module

Ctrl+C command module.

class moler.cmd.unix.ctrl_c.CtrlC(connection, prompt=None, expected_prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unix ctrl+c command

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
command_string

Getter for command_string.

Returns:String with command_string
on_new_line(line, is_full_line)

Parses the output of the command.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.cut module

cut command module.

class moler.cmd.unix.cut.Cut(connection, options=None, path=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unix command cut.

build_command_string()

Build command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.date module

Date command module.

class moler.cmd.unix.date.Date(connection, options=None, date_table_output=True, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.devmem module

Devmem command module.

class moler.cmd.unix.devmem.Devmem(connection, address, size=None, value=None, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Devmem command class.

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.df module

Df command module.

class moler.cmd.unix.df.Df(connection, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.dmesg module

Dmesg command module.

class moler.cmd.unix.dmesg.Dmesg(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.du module

du command module.

class moler.cmd.unix.du.Du(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unix command du.

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.echo module

Echo command module.

class moler.cmd.unix.echo.Echo(connection, options=None, text=None, write_mode='>', output_file=None, prompt=None, newline_chars=None, runner=None, text_in_quotation=True)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()
Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.enter module

enter command module.

class moler.cmd.unix.enter.Enter(connection, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()
Returns:String representation of command to send over connection to device.

moler.cmd.unix.env module

Env command module.

class moler.cmd.unix.env.Env(connection, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.ethtool module

Ethtool command module.

class moler.cmd.unix.ethtool.Ethtool(connection, interface, prompt=None, newline_chars=None, options=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.exit module

Exit command module.

class moler.cmd.unix.exit.Exit(connection, prompt=None, expected_prompt='>', newline_chars=None, runner=None, target_newline='n', allowed_newline_after_prompt=False, start_command_immediately=True)

Bases: moler.cmd.commandchangingprompt.CommandChangingPrompt

build_command_string()

Returns a string with command.

Returns:String with the command.

moler.cmd.unix.exit_telnet module

Exit telnet command

class moler.cmd.unix.exit_telnet.ExitTelnet(connection, newline_chars=None, prompt=None, runner=None, expected_prompt='moler_bash#', set_timeout=None, set_prompt=None, target_newline='n', allowed_newline_after_prompt=False, prompt_after_login=None)

Bases: moler.cmd.commandchangingprompt.CommandChangingPrompt

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.export module

Export command module.

class moler.cmd.unix.export.Export(connection, prompt=None, newline_chars=None, ps1_param=None, set_param=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.find module

Find command module.

class moler.cmd.unix.find.Find(connection, paths=None, prompt=None, newline_chars=None, options=None, operators=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.generictelnetssh module

Base class for telnet and ssh commands.

class moler.cmd.unix.generictelnetssh.GenericTelnetSsh(connection, host, login=None, password=None, newline_chars=None, prompt=None, runner=None, port=0, expected_prompt='^>\s*', set_timeout='export TMOUT=\"2678400\"', set_prompt=None, term_mono='TERM=xterm-mono', encrypt_password=True, target_newline='n', allowed_newline_after_prompt=False, repeat_password=True, failure_exceptions_indication=None, prompt_after_login=None, send_enter_after_connection=True, username=None)

Bases: moler.cmd.commandchangingprompt.CommandChangingPrompt

is_failure_indication(line)

Checks if line contains information that command fails.

Parameters:line – Line from device
Returns:Match object or None
on_new_line(line, is_full_line)

Parses the output of the command.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

Raises:

ParsingDone if any line matched the regex.

moler.cmd.unix.genericunix module

Generic Unix/Linux module

class moler.cmd.unix.genericunix.GenericUnixCommand(connection, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.commandtextualgeneric.CommandTextualGeneric

is_failure_indication(line)

Method to detect if passed line contains part indicating failure of command

Parameters:line – Line from command output on device
Returns:Match object if find regex in line, None otherwise.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.grep module

Grep command module.

class moler.cmd.unix.grep.Grep(connection, options, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.gunzip module

Gunzip command module.

class moler.cmd.unix.gunzip.Gunzip(connection, archive_name, output_file_name=None, options=None, overwrite=False, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.gzip module

Gzip command module.

class moler.cmd.unix.gzip.Gzip(connection, file_name, compressed_file_name=None, options=None, overwrite=False, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.hciconfig module

Hciconfig command module.

class moler.cmd.unix.hciconfig.Hciconfig(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.head module

Head command module.

class moler.cmd.unix.head.Head(connection, path, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Head command class.

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of the command to send over a connection to the device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise.
Returns:

None.

moler.cmd.unix.hexdump module

Hexdump command module.

class moler.cmd.unix.hexdump.Hexdump(connection, files, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.history module

History command module.

class moler.cmd.unix.history.History(connection, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unix command history.

build_command_string()

Build command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.hostname module

Hostname command module.

class moler.cmd.unix.hostname.Hostname(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.id module

id command module.

class moler.cmd.unix.id.Id(connection, user=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.ifconfig module

ifconfig command module.

class moler.cmd.unix.ifconfig.Ifconfig(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.ip_addr module

ip addr command module.

class moler.cmd.unix.ip_addr.IpAddr(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.ip_neigh module

ip addr command module.

class moler.cmd.unix.ip_neigh.IpNeigh(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.ip_route module

ip route command module.

class moler.cmd.unix.ip_route.IpRoute(connection, prompt=None, newline_chars=None, runner=None, is_ipv6=False, addr_get=None, addr_from=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unix command ip route

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
get_default_route()

Helpful method to find default route from command output.

Returns:Default route or None.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise.
Returns:

None.

moler.cmd.unix.iperf module

Iperf command module.

+——————————————————————- | Deprecated module. Don’t develop any more. Develop Iperf2 instead. +——————————————————————-

Deprecation rationale: This command returned value requires additional parsing and doesn’t provide final report.

class moler.cmd.unix.iperf.Iperf(connection, options, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Run iperf command and return its statistics

Statistics are given as list of dicts like:

{'Interval':                 '0.0- 1.0 sec',
 'Transfer Raw':             '1.17 MBytes',
 'Transfer':                 1226833,
 'Bandwidth Raw':            '9.84 Mbits/sec',
 'Bandwidth':                1230000,
 'Jitter':                   '1.830 ms',
 'Lost_vs_Total_Datagrams':  '0/ 837   (0%)'}

Above dict represents iperf output like:

[ ID]   Interval         Transfer        Bandwidth         Jitter        Lost/Total Datagrams
[904]   0.0- 1.0 sec   1.17 MBytes   9.84 Mbits/sec   1.830 ms   0/ 837   (0%)

Please note that numeric values are normalized to Bytes: - Transfer is in Bytes - Bandwith is in Bytes/sec

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.iperf2 module

Iperf2 command module.

It is refactored Iperf module changing data format returned. New format doesn’t require additional post processing of values inside returned dict (it was the case with old one)

Moreover, new format provides final report - see bellow.

iperf2 was orphaned in the late 2000s at version 2.0.5 Then in 2014, Bob (Robert) McMahon from Broadcom restarted development of iperf2 Official iperf2 releases after 2.0.5: https://sourceforge.net/projects/iperf2/files/ Important changes: - starting from 2.0.8 -b may be used to limit bandwidth at TCP - as a consequence -b doesn’t force -u

class moler.cmd.unix.iperf2.Iperf2(connection, options, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand, moler.publisher.Publisher

Run iperf command, return its statistics and report.

Single line of iperf output may look like:

[ ID]   Interval       Transfer      Bandwidth        Jitter   Lost/Total Datagrams
[904]   0.0- 1.0 sec   1.17 MBytes   9.84 Mbits/sec   1.830 ms    0/ 837   (0%)

It represents data transfer statistics reported per given interval. This line is parsed out and produces statistics record as python dict. (examples can be found at bottom of iperf2.py source code) Some keys inside dict are normalized to Bytes. In such case you will see both: raw and normalized values:

'Transfer Raw':     '1.17 MBytes',
'Transfer':         1226833,           # Bytes
'Bandwidth Raw':    '9.84 Mbits/sec',
'Bandwidth':        1230000,           # Bytes/sec

Iperf statistics are stored under connection name with format (client_port@client_IP, server_port@server_IP) It represents iperf output line (iperf server example below) like:

[  3] local 192.168.0.12 port 5016 connected with 192.168.0.10 port 56262
("56262@192.168.0.10", "5016@192.168.0.12"): [<statistics dicts here>]

Iperf returned value has also additional connection named “report connection”. It has format (client_IP, server_port@server_IP) So, for above example you should expect structure like:

("192.168.0.10", "5016@192.168.0.12"): {'report': {<report dict here>}}
build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
client
dualtest
interval
is_end_of_cmd_output(line)

Checks if end of command is reached.

For iperf server we can’t await prompt since at server it is not displayed

Parameters:line – Line from device.
Returns:
on_inactivity()

Call when no data is received on connection within self.life_status.inactivity_timeout seconds.

Returns:None
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

parallel_client
protocol
server
singlerun_server
subscribe(subscriber)

Subscribe for notifications about iperf statistic as it comes.

Anytime we find iperf statistics line like: [ 3] 2.0- 3.0 sec 612 KBytes 5010 Kbits/sec 0.022 ms 0/ 426 (0%) such line is parsed and published to subscriber

Subscriber must be function or method with following signature (name doesn’t matter):

def iperf_observer(from_client, to_server, data_record=None, report=None):

Either data_record is published or report. Report is published on last line of iperf statistics summarizing stats for whole period: [904] 0.0-10.0 sec 11.8 MBytes 9.86 Mbits/sec 2.618 ms 9/ 8409 (0.11%)

Parameters:subscriber – function to be called to notify about data.
time
works_in_dualtest

moler.cmd.unix.ipsec module

Ipsec command module.

class moler.cmd.unix.ipsec.Ipsec(connection, options, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.iptables module

iptables command module.

class moler.cmd.unix.iptables.Iptables(connection, options=None, v6=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.kill module

kill command module.

class moler.cmd.unix.kill.Kill(connection, pid, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.killall module

Killall command module.

class moler.cmd.unix.killall.Killall(connection, name, is_verbose=False, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.ln module

Ln command module.

class moler.cmd.unix.ln.Ln(connection, prompt=None, newline_chars=None, options=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.logout module

Logout command module.

class moler.cmd.unix.logout.Logout(connection, prompt=None, expected_prompt='>', newline_chars=None, runner=None, target_newline='n', allowed_newline_after_prompt=False, start_command_immediately=True)

Bases: moler.cmd.unix.exit.Exit

build_command_string()

Returns a string with command.

Returns:String with the command.

moler.cmd.unix.ls module

Ls command module.

class moler.cmd.unix.ls.Ls(connection, prompt=None, newline_chars=None, options=None, path=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unix command ls

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
get_dirs()

Returns only directories (folders) from command output

Returns:Dict, key is item, value is parsed information about item
get_files()

Returns only files from command output

Returns:Dict, key is item, value is parsed information about item

Returns only links from command output

Returns:Dict, key is item, value is parsed information about item
on_new_line(line, is_full_line)

Processes line from output form connection/device.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.lsof module

lsof command module.

class moler.cmd.unix.lsof.Lsof(connection, prompt=None, newline_chars=None, runner=None, options=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unix lsof command

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Parses the output of the command.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.lxc_attach module

LxcAttach command module.

moler.cmd.unix.lxc_attach.COMMAND_RESULT_2 = {}

=================================================HELP=MESSAGE=========================================================== root@0xe000:~ >lxc-attach –help Usage: lxc-attach –name=NAME [– COMMAND]

Execute the specified COMMAND - enter the container NAME

Options :
-n, --name=NAME
 NAME of the container
-e, --elevated-privileges=PRIVILEGES
 Use elevated privileges instead of those of the container. If you don’t specify privileges to be elevated as OR’d list: CAP, CGROUP and LSM (capabilities, cgroup and restrictions, respectively) then all of them will be elevated. WARNING: This may leak privileges into the container. Use with care.
-a, --arch=ARCH
 Use ARCH for program instead of container’s own architecture.
-s, --namespaces=FLAGS
 Don’t attach to all the namespaces of the container but just to the following OR’d list of flags: MOUNT, PID, UTSNAME, IPC, USER or NETWORK. WARNING: Using -s implies -e with all privileges elevated, it may therefore leak privileges into the container. Use with care.
-R, --remount-sys-proc
 
Remount /sys and /proc if not attaching to the mount namespace when using -s in order to properly reflect the correct namespace context. See the lxc-attach(1) manual page for details.
--clear-env Clear all environment variables before attaching. The attached shell/program will start with only container=lxc set.
--keep-env Keep all current environment variables. This is the current default behaviour, but is likely to change in the future.
-L, --pty-log=FILE
 Log pty output to FILE
-v, --set-var
Set an additional variable that is seen by the
attached program in the container. May be specified multiple times.
--keep-var Keep an additional environment variable. Only applicable if –clear-env is specified. May be used multiple times.
-f, --rcfile=FILE
 Load configuration file FILE
Common options :
-o, --logfile=FILE
 Output log to FILE instead of stderr
-l, --logpriority=LEVEL
 Set log priority to LEVEL
-q, --quiet Don’t produce any output
-P, --lxcpath=PATH
 Use specified container path
-?, –help Give this help list
--usage Give a short usage message
--version Print the version number

Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options.

See the lxc-attach man page for further information.

class moler.cmd.unix.lxc_attach.LxcAttach(name, connection, prompt=None, newline_chars=None, runner=None, options=None, expected_prompt=None)

Bases: moler.cmd.commandchangingprompt.CommandChangingPrompt

LxcAttach command class.

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.lxc_info module

LxcInfo command module.

moler.cmd.unix.lxc_info.COMMAND_RESULT_2 = {'RESULT': {'State': 'RUNNING'}}

=================================================HELP=MESSAGE=========================================================== root@server~ >lxc-info –help Usage: lxc-info –name=NAME

lxc-info display some information about a container with the identifier NAME

Options :
-n, --name=NAME
 NAME of the container
-c, --config=KEY
 show configuration variable KEY from running container
-i, --ips shows the IP addresses
-p, --pid shows the process id of the init container
-S, --stats shows usage stats
-H, --no-humanize
 shows stats as raw numbers, not humanized
-s, --state shows the state of the container
--rcfile=FILE Load configuration file FILE
Common options :
-o, --logfile=FILE
 Output log to FILE instead of stderr
-l, --logpriority=LEVEL
 Set log priority to LEVEL
-q, --quiet Don’t produce any output
-P, --lxcpath=PATH
 Use specified container path
-?, –help Give this help list
--usage Give a short usage message
--version Print the version number

Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options.

See the lxc-info man page for further information.

class moler.cmd.unix.lxc_info.LxcInfo(name, connection, prompt=None, newline_chars=None, runner=None, options=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

LxcInfo command class.

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.lxc_ls module

LxcLs command module.

moler.cmd.unix.lxc_ls.COMMAND_RESULT_3 = {'RESULT': [['0xe000', '0xe000/0xe000', '0xe000/0xe001', '0xe000/0xe002', '0xe000/0xe003', '0xe000/0xe004', '0xe000/0xe009', '0xe000/0xe00a', '0xe000/0xe00b', '0xe000/0xe00c', '0xe000/0xe00d'], ['0xe000/0xe019', '0xe001', '0xe002', '0xe002/0xe000', '0xe002/0xe001', '0xe002/0xe002', '0xe002/0xe003', '0xe002/0xe004', '0xe002/0xe009', '0xe002/0xe00a', '0xe002/0xe00b'], ['0xe002/0xe00c', '0xe002/0xe00d', '0xe002/0xe019', '0xe003', '0xe003/0xe000', '0xe003/0xe001', '0xe003/0xe002', '0xe003/0xe003', '0xe003/0xe004', '0xe003/0xe009', '0xe003/0xe00a'], ['0xe003/0xe00b', '0xe003/0xe00c', '0xe003/0xe00d', '0xe003/0xe019', '0xe004', '0xe004/0xe000', '0xe004/0xe001', '0xe004/0xe002', '0xe004/0xe003', '0xe004/0xe004', '0xe004/0xe009'], ['0xe004/0xe00a', '0xe004/0xe00b', '0xe004/0xe00c', '0xe004/0xe00d', '0xe004/0xe019', '0xe009', '0xe00a', '0xe00a/0xe000', '0xe00a/0xe001', '0xe00a/0xe002', '0xe00a/0xe003'], ['0xe00a/0xe004', '0xe00a/0xe009', '0xe00a/0xe00a', '0xe00a/0xe00b', '0xe00a/0xe00c', '0xe00a/0xe00d', '0xe00a/0xe019', '0xe00b', '0xe00c', '0xe00d', '0xe019'], ['0xe019/0xe000', '0xe019/0xe001', '0xe019/0xe002', '0xe019/0xe003', '0xe019/0xe004', '0xe019/0xe009', '0xe019/0xe00a', '0xe019/0xe00b', '0xe019/0xe00c', '0xe019/0xe00d', '0xe019/0xe019']]}

==================================================HELP=MESSAGE========================================================== root@0xe000:~ >lxc-ls –help Usage: lxc-ls [-P lxcpath] [–active] [–running] [–frozen] [–stopped] [–nesting] [-g groups] [–filter regex] [-1] [-P lxcpath] [–active] [–running] [–frozen] [–stopped] [–nesting] [-g groups] [–filter regex] [-f] [-P lxcpath] [–active] [–running] [–frozen] [–stopped] [–nesting] [-g groups] [–filter regex]

lxc-ls list containers

Options :
-1, --line show one entry per line
-f, --fancy use a fancy, column-based output
-F, –fancy-format comma separated list of columns to show in the fancy output
valid columns are: NAME, STATE, PID, RAM, SWAP, AUTOSTART, GROUPS, INTERFACE, IPV4 and IPV6
--active list only active containers
--running list only running containers
--frozen list only frozen containers
--stopped list only stopped containers
--defined list only defined containers
--nesting=NUM list nested containers up to NUM (default is 5) levels of nesting
--filter=REGEX filter container names by regular expression

-g –groups comma separated list of groups a container must have to be displayed

Common options :
-o, --logfile=FILE
 Output log to FILE instead of stderr
-l, --logpriority=LEVEL
 Set log priority to LEVEL
-q, --quiet Don’t produce any output
-P, --lxcpath=PATH
 Use specified container path
-?, –help Give this help list
--usage Give a short usage message
--version Print the version number

Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options.

See the lxc-ls man page for further information.

root@0xe000:~ >

class moler.cmd.unix.lxc_ls.LxcLs(connection, prompt=None, newline_chars=None, runner=None, options=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Lxcls command class.

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.md5sum module

Md5sum command module.

class moler.cmd.unix.md5sum.Md5sum(connection, path, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.mkdir module

Mkdir command module.

class moler.cmd.unix.mkdir.Mkdir(connection, path, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.mount module

Mount command module.

class moler.cmd.unix.mount.Mount(connection, options=None, device=None, directory=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.mpstat module

Mpstat command module.

class moler.cmd.unix.mpstat.Mpstat(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unix mpstat command

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Parses the command output.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.mv module

Mv command module.

class moler.cmd.unix.mv.Mv(connection, src, dst, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.netstat module

class moler.cmd.unix.netstat.Netstat(connection, options='', prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Netstat command class.

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of the command to send over a connection to the device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.nft module

nft command module.

class moler.cmd.unix.nft.Nft(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.nmap module

Nmap command module.

class moler.cmd.unix.nmap.Nmap(connection, ip, is_ping=False, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()
Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.ntpq module

Ntpq command module.

class moler.cmd.unix.ntpq.Ntpq(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.openssl_s_client module

openssl s_client command module.

class moler.cmd.unix.openssl_s_client.OpensslSClient(connection, options, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

openssl command s_client

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Parse command output.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.openssl_x509_text_in module

openssl_x509_text_in module.

class moler.cmd.unix.openssl_x509_text_in.OpensslX509TextIn(connection, path=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Command openssl_x509_text_in.

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.passwd module

Passwd command module.

class moler.cmd.unix.passwd.Passwd(connection, current_password=None, new_password=None, user=None, options=None, encrypt_password=True, newline_chars=None, runner=None, prompt=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Parses the output of the command.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.ping module

Ping command module.

class moler.cmd.unix.ping.Ping(connection, destination, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.pkill module

Pkill command module.

class moler.cmd.unix.pkill.Pkill(connection, name, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.ps module

class moler.cmd.unix.ps.Ps(connection=None, options='', prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unix command ps.

build_command_string()

Builds string with command.

Returns:String with command.
on_new_line(line, is_full_line)

Parses output from command.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.pwd module

pwd command module.

class moler.cmd.unix.pwd.Pwd(connection, prompt=None, newline_chars=None, runner=None, options=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Processes line from output form connection/device.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise.
Returns:

None.

moler.cmd.unix.reboot module

Reboot command module.

class moler.cmd.unix.reboot.Reboot(connection, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. :param line: Line to parse, new lines are trimmed :param is_full_line: False for chunk of line; True on full line (NOTE: new line character removed) :return: None

moler.cmd.unix.rm module

Rm command module.

class moler.cmd.unix.rm.Rm(connection, file, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

moler.cmd.unix.route module

Route command module.

class moler.cmd.unix.route.Route(connection, prompt=None, newline_chars=None, options=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.run_script module

Run script command

class moler.cmd.unix.run_script.RunScript(connection, script_command, error_regex=re.compile('error', re.IGNORECASE), prompt=None, newline_chars=None, runner=None, success_regex=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.run_serial_proxy module

Run moler_serial_proxy command

class moler.cmd.unix.run_serial_proxy.RunSerialProxy(connection, serial_devname, prompt=None, newline_chars=None, target_newline='n', runner=None)

Bases: moler.cmd.commandchangingprompt.CommandChangingPrompt

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Parses the output of the command.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise.
Returns:

None.

moler.cmd.unix.scp module

SCP command module.

class moler.cmd.unix.scp.Scp(connection, source, dest, password='', options='', prompt=None, newline_chars=None, known_hosts_on_failure='keygen', encrypt_password=True, runner=None, repeat_password=True)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise.
Returns:

None.

moler.cmd.unix.sed module

Sed command module.

class moler.cmd.unix.sed.Sed(connection, input_files, prompt=None, newline_chars=None, runner=None, options=None, scripts=None, script_files=None, output_file=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.service module

Service command module.

class moler.cmd.unix.service.Service(connection, options, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.sftp module

SFTP command module.

class moler.cmd.unix.sftp.Sftp(connection, host, password, user=None, confirm_connection=True, source_path=None, destination_path=None, options=None, command=None, no_result=False, prompt=None, newline_chars=None, timeout=60, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.shasum module

Shasum command module.

class moler.cmd.unix.shasum.Shasum(connection, path, options=None, cmd_kind='shasum', prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string form parameters.

Returns:Command string
on_new_line(line, is_full_line)

Parses every line from connection.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.socat module

Socat command module.

class moler.cmd.unix.socat.Socat(connection, input_options=None, output_options=None, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.ss module

class moler.cmd.unix.ss.Ss(connection, options='', prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Ss command class.

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of the command to send over a connection to the device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.ssh module

Ssh command module.

class moler.cmd.unix.ssh.Ssh(connection, login=None, password=None, host='0', prompt=None, expected_prompt='>', port=0, known_hosts_on_failure='keygen', set_timeout='export TMOUT=\"2678400\"', set_prompt=None, term_mono='TERM=xterm-mono', newline_chars=None, encrypt_password=True, runner=None, target_newline='n', allowed_newline_after_prompt=False, repeat_password=True, options='-o ServerAliveInterval=7 -o ServerAliveCountMax=2', failure_exceptions_indication=None, prompt_after_login=None, send_enter_after_connection=True, username=None, permission_denied_key_pass_keyboard='ssh-keygen -f "~/.ssh/known_hosts" -R "{host}"', allow_override_denied_key_pass_keyboard=True, suffix=None)

Bases: moler.cmd.unix.generictelnetssh.GenericTelnetSsh

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Parses the output of the command.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.sshkeygen module

Ssh-keygen command module.

class moler.cmd.unix.sshkeygen.Sshkeygen(connection, prompt=None, newline_chars=None, options=None, file='/home/ute/.ssh/id_rsa', passphrase='', overwrite=True, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise.
Returns:

None.

moler.cmd.unix.su module

Su command module.

class moler.cmd.unix.su.Su(connection, login=None, options=None, password=None, prompt=None, expected_prompt=None, newline_chars=None, encrypt_password=True, target_newline='n', runner=None, set_timeout=None, allowed_newline_after_prompt=False, set_prompt=None, prompt_after_login=None, cmd_object=None, cmd_class_name=None, cmd_params=None, repeat_password=None)

Bases: moler.cmd.unix.sudo.Sudo

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.

moler.cmd.unix.sudo module

Sudo command module.

class moler.cmd.unix.sudo.Sudo(connection, password=None, sudo_params=None, cmd_object=None, cmd_class_name=None, cmd_params=None, prompt=None, newline_chars=None, runner=None, encrypt_password=True, expected_prompt=None, set_timeout=None, set_prompt=None, target_newline='n', allowed_newline_after_prompt=False, prompt_after_login=None, repeat_password=True)

Bases: moler.cmd.commandchangingprompt.CommandChangingPrompt

Unix command sudo

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise.
Returns:

None.

start(timeout=None, *args, **kwargs)

Start background execution of connection-observer.

moler.cmd.unix.sync module

Sync command module.

class moler.cmd.unix.sync.Sync(connection, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

moler.cmd.unix.systemctl module

Systemctl command module.

class moler.cmd.unix.systemctl.Systemctl(connection, options=None, service=None, password=None, prompt=None, newline_chars=None, runner=None, encrypt_password=True)

Bases: moler.cmd.unix.service.Service

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise.
Returns:

None.

moler.cmd.unix.tail module

Tail command module.

class moler.cmd.unix.tail.Tail(connection, path, options=None, prompt=None, newline_chars=None, runner=None, failure_only_in_first_line=True)

Bases: moler.cmd.unix.cat.Cat

build_command_string()

Builds string with command.

Returns:String with command.

moler.cmd.unix.tail_latest_file module

Tail latest file from the directory.

class moler.cmd.unix.tail_latest_file.TailLatestFile(connection, directory, file_pattern='*', prompt=None, newline_chars=None, runner=None, time_for_failure=0.1)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
is_failure_indication(line)

Check if line has info about failure indication.

Parameters:line – Line from device
Returns:None if line does not match regex with failure, Match object if line matches the failure regex.
on_new_line(line, is_full_line)

Parse line from command output.

Parameters:
  • line – Line from device
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.tar module

tar command module.

class moler.cmd.unix.tar.Tar(connection, options, file, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.

moler.cmd.unix.tcpdump module

Tcpdump command module.

class moler.cmd.unix.tcpdump.Tcpdump(connection, options=None, prompt=None, newline_chars=None, runner=None, break_exec_regex=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.tee module

Tee command module.

class moler.cmd.unix.tee.Tee(connection, path, content, border='END_OF_FILE', prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unix tee command

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Parses the output of the command.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.telnet module

Telnet command module.

class moler.cmd.unix.telnet.Telnet(connection, host, login=None, password=None, port=0, prompt=None, expected_prompt='^>\s*', set_timeout='export TMOUT=\"2678400\"', set_prompt=None, term_mono='TERM=xterm-mono', prefix=None, newline_chars=None, cmds_before_establish_connection=None, cmds_after_establish_connection=None, telnet_prompt='^\s*telnet>\s*', encrypt_password=True, runner=None, target_newline='n', allowed_newline_after_prompt=False, repeat_password=True, failure_exceptions_indication=None, prompt_after_login=None, send_enter_after_connection=True, username=None)

Bases: moler.cmd.unix.generictelnetssh.GenericTelnetSsh

build_command_string()

Builds command string from parameters passed to object.

Returns:String representation of command to send over connection to device.
on_new_line(line, is_full_line)

Parses the output of the command.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.top module

Top command module.

class moler.cmd.unix.top.Top(connection, options=None, prompt=None, newline_chars=None, runner=None, n=1)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.traceroute module

Traceroute command module.

class moler.cmd.unix.traceroute.Traceroute(connection, destination, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.tshark module

Tshark command module.

class moler.cmd.unix.tshark.Tshark(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.uname module

Uname command module.

class moler.cmd.unix.uname.Uname(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.unxz module

class moler.cmd.unix.unxz.Unxz(connection, xz_file, options='', prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unxz command class.

build_command_string()

Build command string from parameters passed to object. :return: String representation of the command to send over a connection to the device.

moler.cmd.unix.unzip module

class moler.cmd.unix.unzip.Unzip(connection, zip_file, extract_dir=None, options='', overwrite=False, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

Unzip command class.

build_command_string()

Build command string from parameters passed to object.

Returns:String representation of the command to send over a connection to the device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None.

moler.cmd.unix.uptime module

Uptime command module.

class moler.cmd.unix.uptime.Uptime(connection, options=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Builds command string from parameters passed to object. :return: String representation of command to send over connection to device.

on_new_line(line, is_full_line)

Put your parsing code here. :param line: Line to process, can be only part of line. New line chars are removed from line. :param is_full_line: True if line had new line chars, False otherwise :return: None

moler.cmd.unix.useradd module

Useradd command module.

class moler.cmd.unix.useradd.Useradd(connection, prompt=None, newline_chars=None, runner=None, options=None, defaults=False, user=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.userdel module

Userdel command module.

class moler.cmd.unix.userdel.Userdel(connection, prompt=None, newline_chars=None, runner=None, options=None, user=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.w module

class moler.cmd.unix.w.W(connection, options='', prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

W command class.

build_command_string()

Build command string from parameters passed to object. Usage of paramter -h in options is going to be ignored.

Returns:String representation of the command to send over a connection to the device.
on_new_line(line, is_full_line)

Put your parsing code here.

Parameters:
  • line – Line to process, can be only part of line. New line chars are removed from line.
  • is_full_line – True if line had new line chars, False otherwise
Returns:

None

moler.cmd.unix.wget module

Wget command module.

class moler.cmd.unix.wget.Wget(connection, options, log_progress_bar=False, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.which module

Which command module.

class moler.cmd.unix.which.Which(connection, names, show_all=None, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.whoami module

Whoami command module.

class moler.cmd.unix.whoami.Whoami(connection, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

moler.cmd.unix.zip module

Zip command module.

class moler.cmd.unix.zip.Zip(connection, options, file_name, zip_file, timeout=60, prompt=None, newline_chars=None, runner=None)

Bases: moler.cmd.unix.genericunix.GenericUnixCommand

build_command_string()

Returns string with command constructed with parameters of object.

Returns:String with command.
on_new_line(line, is_full_line)

Method to parse command output. Will be called after line with command echo. Write your own implementation but don’t forget to call on_new_line from base class

Parameters:
  • line – Line to parse, new lines are trimmed
  • is_full_line – False for chunk of line; True on full line (NOTE: new line character removed)
Returns:

None

Module contents

Package for implementing Unix/Linux commands.