Skip to content

Commit

Permalink
Chane new_line_chars into newline_chars
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernold11 committed Oct 15, 2018
1 parent 4b62048 commit 5452e07
Show file tree
Hide file tree
Showing 73 changed files with 158 additions and 158 deletions.
16 changes: 8 additions & 8 deletions moler/cmd/commandtextualgeneric.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

class CommandTextualGeneric(Command):
_re_default_prompt = re.compile(r'^[^<]*[\$|%|#|>|~]\s*$') # When user provides no prompt
_default_new_line_chars = ("\n", "\r") # New line chars on device, not system with script!
_default_newline_chars = ("\n", "\r") # New line chars on device, not system with script!

def __init__(self, connection, prompt=None, new_line_chars=None, runner=None):
def __init__(self, connection, prompt=None, newline_chars=None, runner=None):
"""
:param connection: connection to device
:param prompt: expected prompt sending by device after command execution. Maybe String or compiled re
:param new_line_chars: new line chars on device
:param newline_chars: new line chars on device
"""
super(CommandTextualGeneric, self).__init__(connection=connection, runner=runner)
self.__command_string = None # String representing command on device
Expand All @@ -37,9 +37,9 @@ def __init__(self, connection, prompt=None, new_line_chars=None, runner=None):
self.break_on_timeout = True # If True then Ctrl+c on timeout
self._last_not_full_line = None # Part of line
self._re_prompt = CommandTextualGeneric._calculate_prompt(prompt) # Expected prompt on device
self._new_line_chars = new_line_chars # New line characters on device
if not self._new_line_chars:
self._new_line_chars = CommandTextualGeneric._default_new_line_chars
self._newline_chars = newline_chars # New line characters on device
if not self._newline_chars:
self._newline_chars = CommandTextualGeneric._default_newline_chars

@property
def command_string(self):
Expand Down Expand Up @@ -67,7 +67,7 @@ def has_endline_char(self, line):
:param line: String to check
:return: True if any new line char was found, False otherwise
"""
if line.endswith(self._new_line_chars):
if line.endswith(self._newline_chars):
return True
return False

Expand Down Expand Up @@ -125,7 +125,7 @@ def _strip_new_lines_chars(self, line):
:param line: line from device
:return: line without new lines chars
"""
for char in self._new_line_chars:
for char in self._newline_chars:
line = line.rstrip(char)
return line

Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

class Bash(GenericUnixCommand):

def __init__(self, connection, prompt=None, new_line_chars=None, runner=None, bash="TERM=xterm-mono bash"):
super(Bash, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, prompt=None, newline_chars=None, runner=None, bash="TERM=xterm-mono bash"):
super(Bash, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.bash = bash
self.ret_required = False

Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@


class Cat(GenericUnixCommand):
def __init__(self, connection, path, options=None, prompt=None, new_line_chars=None, runner=None):
super(Cat, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, path, options=None, prompt=None, newline_chars=None, runner=None):
super(Cat, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.path = path
self.options = options
self.current_ret["LINES"] = []
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

class Cd(GenericUnixCommand):

def __init__(self, connection, path=None, prompt=None, new_line_chars=None, runner=None):
super(Cd, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, path=None, prompt=None, newline_chars=None, runner=None):
super(Cd, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)

# Parameters defined by calling the command
self.path = path
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/chgrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@


class Chgrp(GenericUnixCommand):
def __init__(self, connection, files, group, options=None, prompt=None, new_line_chars=None, runner=None):
super(Chgrp, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, files, group, options=None, prompt=None, newline_chars=None, runner=None):
super(Chgrp, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.options = options
self.files = files
self.group = group
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/chmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@


class Chmod(GenericUnixCommand):
def __init__(self, connection, permission, filename, options=None, prompt=None, new_line_chars=None, runner=None):
super(Chmod, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, permission, filename, options=None, prompt=None, newline_chars=None, runner=None):
super(Chmod, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.permission = permission
self.filename = filename
self.options = options
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/chown.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@


class Chown(GenericUnixCommand):
def __init__(self, connection, param, filename, options=None, prompt=None, new_line_chars=None, runner=None):
super(Chown, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, param, filename, options=None, prompt=None, newline_chars=None, runner=None):
super(Chown, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.param = param
self.filename = filename
self.options = options
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@


class Cp(GenericUnixCommand):
def __init__(self, connection, src, dst, options=None, prompt=None, new_line_chars=None, runner=None):
super(Cp, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, src, dst, options=None, prompt=None, newline_chars=None, runner=None):
super(Cp, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)

self.src = src
self.dst = dst
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/date.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@


class Date(GenericUnixCommand):
def __init__(self, connection, prompt=None, new_line_chars=None, runner=None):
super(Date, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, prompt=None, newline_chars=None, runner=None):
super(Date, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)

# Parameters defined by calling the command

Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/df.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

class Df(GenericUnixCommand):

def __init__(self, connection, prompt=None, new_line_chars=None, runner=None):
super(Df, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, prompt=None, newline_chars=None, runner=None):
super(Df, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self._converter_helper = ConverterHelper()

def build_command_string(self):
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/dmesg.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@


class Dmesg(GenericUnixCommand):
def __init__(self, connection, options=None, prompt=None, new_line_chars=None, runner=None):
super(Dmesg, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, options=None, prompt=None, newline_chars=None, runner=None):
super(Dmesg, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.options = options
self.current_ret["LINES"] = []

Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

class Echo(GenericUnixCommand):
def __init__(self, connection, options=None, text=None, write_mode=">", output_file=None, prompt=None,
new_line_chars=None, runner=None):
super(Echo, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
newline_chars=None, runner=None):
super(Echo, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)

self.options = options
self.text = text
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/enter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

class Enter(GenericUnixCommand):

def __init__(self, connection, prompt=None, new_line_chars=None, runner=None):
super(Enter, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, prompt=None, newline_chars=None, runner=None):
super(Enter, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.ret_required = False

def build_command_string(self):
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

class Env(GenericUnixCommand):

def __init__(self, connection, prompt=None, new_line_chars=None, runner=None):
super(Env, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, prompt=None, newline_chars=None, runner=None):
super(Env, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.ret_required = True

def build_command_string(self):
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/ethtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

class Ethtool(GenericUnixCommand):

def __init__(self, connection, interface, prompt=None, new_line_chars=None, options=None, runner=None):
super(Ethtool, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars,
def __init__(self, connection, interface, prompt=None, newline_chars=None, options=None, runner=None):
super(Ethtool, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars,
runner=runner)
self.interface = interface
self.options = options
Expand Down
6 changes: 3 additions & 3 deletions moler/cmd/unix/exit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@


class Exit(GenericUnixCommand):
def __init__(self, connection, prompt=None, expected_prompt='>', new_line_chars=None, runner=None, target_newline="\n"):
def __init__(self, connection, prompt=None, expected_prompt='>', newline_chars=None, runner=None, target_newline="\n"):
"""
:param connection:
:param prompt: Prompt of the starting shell
:param expected_prompt: Prompt of the target shell reached after exit command
:param new_line_chars:
:param newline_chars:
"""
super(Exit, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
super(Exit, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.ret_required = False
self.target_newline = target_newline

Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

class Export(GenericUnixCommand):

def __init__(self, connection, prompt=None, new_line_chars=None, ps1_param=None, set_param=None, runner=None):
super(Export, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, prompt=None, newline_chars=None, ps1_param=None, set_param=None, runner=None):
super(Export, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
if ps1_param or set_param:
self.ret_required = False
else:
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@


class Find(GenericUnixCommand):
def __init__(self, connection, paths=[], prompt=None, new_line_chars=None, options=None, operators=None,
def __init__(self, connection, paths=[], prompt=None, newline_chars=None, options=None, operators=None,
runner=None):
super(Find, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
super(Find, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.options = options
self.operators = operators
self.paths = copy.copy(paths)
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/genericunix.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
class GenericUnixCommand(CommandTextualGeneric):
_re_fail = re.compile(r'command not found|No such file or directory|running it may require superuser privileges')

def __init__(self, connection, prompt=None, new_line_chars=None, runner=None):
super(GenericUnixCommand, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars,
def __init__(self, connection, prompt=None, newline_chars=None, runner=None):
super(GenericUnixCommand, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars,
runner=runner)
self.remove_colors_from_terminal_output = True

Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/grep.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

class Grep(GenericUnixCommand):

def __init__(self, connection, options, prompt=None, new_line_chars=None, runner=None):
super(Grep, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, options, prompt=None, newline_chars=None, runner=None):
super(Grep, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self._convert_helper = ConverterHelper()
# Parameters defined by calling the command
self.options = options
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/hciconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


class Hciconfig(GenericUnixCommand):
def __init__(self, connection, options=None, prompt=None, new_line_chars=None, runner=None):
super(Hciconfig, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars,
def __init__(self, connection, options=None, prompt=None, newline_chars=None, runner=None):
super(Hciconfig, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars,
runner=runner)
self.if_name = None
self.options = options
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/hexdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


class Hexdump(GenericUnixCommand):
def __init__(self, connection, files, options=None, prompt=None, new_line_chars=None, runner=None):
super(Hexdump, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars,
def __init__(self, connection, files, options=None, prompt=None, newline_chars=None, runner=None):
super(Hexdump, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars,
runner=runner)
self.options = options
self.files = files
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

class Hostname(GenericUnixCommand):

def __init__(self, connection, options=None, prompt=None, new_line_chars=None, runner=None):
super(Hostname, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars,
def __init__(self, connection, options=None, prompt=None, newline_chars=None, runner=None):
super(Hostname, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars,
runner=runner)
self.options = options

Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/id.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

class Id(GenericUnixCommand):

def __init__(self, connection, user=None, prompt=None, new_line_chars=None, runner=None):
super(Id, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, user=None, prompt=None, newline_chars=None, runner=None):
super(Id, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)

# Parameters defined by calling the command
self.user = user
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/ifconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


class Ifconfig(GenericUnixCommand):
def __init__(self, connection, options=None, prompt=None, new_line_chars=None, runner=None):
super(Ifconfig, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars,
def __init__(self, connection, options=None, prompt=None, newline_chars=None, runner=None):
super(Ifconfig, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars,
runner=runner)
# Parameters defined by calling the command
self.ret_required = False
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/ip_addr.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


class IpAddr(GenericUnixCommand):
def __init__(self, connection, options=None, prompt=None, new_line_chars=None, runner=None):
super(IpAddr, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, options=None, prompt=None, newline_chars=None, runner=None):
super(IpAddr, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
# Parameters defined by calling the command
self.if_name = None
self.options = options
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/ip_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


class IpLink(GenericUnixCommand):
def __init__(self, connection, action, prompt=None, new_line_chars=None, options=None, runner=None):
super(IpLink, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, action, prompt=None, newline_chars=None, options=None, runner=None):
super(IpLink, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.ret_required = False
self.action = action
self.options = options
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/ip_neigh.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


class IpNeigh(GenericUnixCommand):
def __init__(self, connection, options=None, prompt=None, new_line_chars=None, runner=None):
super(IpNeigh, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars,
def __init__(self, connection, options=None, prompt=None, newline_chars=None, runner=None):
super(IpNeigh, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars,
runner=runner)
self.options = options
self.ret_required = False
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/ip_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

class IpRoute(GenericUnixCommand):

def __init__(self, connection, prompt=None, new_line_chars=None, runner=None, is_ipv6=False, addr_get=None,
def __init__(self, connection, prompt=None, newline_chars=None, runner=None, is_ipv6=False, addr_get=None,
addr_from=None):
super(IpRoute, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars,
super(IpRoute, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars,
runner=runner)
self._converter_helper = ConverterHelper()
# Parameters defined by calling the command
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/iperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@


class Iperf(GenericUnixCommand):
def __init__(self, connection, options, prompt=None, new_line_chars=None, runner=None):
super(Iperf, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, options, prompt=None, newline_chars=None, runner=None):
super(Iperf, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.options = options
self.current_ret['CONNECTIONS'] = dict()
self.current_ret['INFO'] = list()
Expand Down
4 changes: 2 additions & 2 deletions moler/cmd/unix/ipsec.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

class Ipsec(GenericUnixCommand):

def __init__(self, connection, options, prompt=None, new_line_chars=None, runner=None):
super(Ipsec, self).__init__(connection=connection, prompt=prompt, new_line_chars=new_line_chars, runner=runner)
def __init__(self, connection, options, prompt=None, newline_chars=None, runner=None):
super(Ipsec, self).__init__(connection=connection, prompt=prompt, newline_chars=newline_chars, runner=runner)
self.options = options
self.ret_required = False

Expand Down
Loading

0 comments on commit 5452e07

Please sign in to comment.