[CLN] linter

This commit is contained in:
Benedek Racz 2020-02-19 16:13:29 +01:00
parent f6ff2fcf4d
commit 4b512294ee
2 changed files with 14 additions and 8 deletions

View File

@ -262,7 +262,7 @@ class ConsoleReaderBase:
self.consin = win32console.GetStdHandle(win32console.STD_INPUT_HANDLE) self.consin = win32console.GetStdHandle(win32console.STD_INPUT_HANDLE)
rect = win32console.PySMALL_RECTType(0, 0, window_size_x-1, window_size_y-1) rect = win32console.PySMALL_RECTType(0, 0, window_size_x - 1, window_size_y - 1)
consout.SetConsoleWindowInfo(True, rect) consout.SetConsoleWindowInfo(True, rect)
size = win32console.PyCOORDType(buffer_size_x, buffer_size_y) size = win32console.PyCOORDType(buffer_size_x, buffer_size_y)
consout.SetConsoleScreenBufferSize(size) consout.SetConsoleScreenBufferSize(size)

View File

@ -97,7 +97,7 @@ init_logger(logger)
def run(command, timeout=-1, withexitstatus=False, events=None, extra_args=None, logfile=None, def run(command, timeout=-1, withexitstatus=False, events=None, extra_args=None, logfile=None,
cwd=None, env=None, **kwargs): cwd=None, env=None, **kwargs):
""" """
This function runs the given command; waits for it to finish; then This function runs the given command; waits for it to finish; then
returns all output as a string. STDERR is included in output. If the full returns all output as a string. STDERR is included in output. If the full
@ -181,7 +181,7 @@ def run(command, timeout=-1, withexitstatus=False, events=None, extra_args=None,
child_result_list.append(child.before) child_result_list.append(child.before)
if type(responses[index]) in (str,): if type(responses[index]) in (str,):
child.send(responses[index]) child.send(responses[index])
elif type(responses[index]) is types.FunctionType: elif isinstance(responses[index], types.FunctionType):
callback_result = responses[index](locals()) callback_result = responses[index](locals())
sys.stdout.flush() sys.stdout.flush()
if type(callback_result) in (str,): if type(callback_result) in (str,):
@ -261,13 +261,19 @@ class SpawnBase:
self.interact_state = interact self.interact_state = interact
# If command is an int type then it may represent a file descriptor. # If command is an int type then it may represent a file descriptor.
if type(command) == type(0): if isinstance(command, int):
logger.warning("ExceptionPexpect('Command is an int type. If this is a file descriptor then maybe you want to use fdpexpect.fdspawn which takes an existing file descriptor instead of a command string.')") logger.warning(
raise ExceptionPexpect('Command is an int type. If this is a file descriptor then maybe you want to use fdpexpect.fdspawn which takes an existing file descriptor instead of a command string.') "ExceptionPexpect :'Command is an int type. If this is a file descriptor then maybe"
" you want to use fdpexpect.fdspawn which takes an existing file descriptor instead"
" of a command string.')")
raise ExceptionPexpect(
'Command is an int type. If this is a file descriptor then maybe you want to use'
' fdpexpect.fdspawn which takes an existing file descriptor instead of a command '
'string.')
if type (args) != type([]): if not isinstance(args, list):
logger.warning("TypeError ('The argument, args, must be a list.')") logger.warning("TypeError ('The argument, args, must be a list.')")
raise TypeError ('The argument, args, must be a list.') raise TypeError('The argument, args, must be a list.')
if args == []: if args == []:
self.args = split_command_line(command) self.args = split_command_line(command)