I am writing a Python script which will ssh into a box(using parakimo) and run a command. I wanted to make a object for the stdout/stderr and print out the output.
Am I passing the list correctly into the class? and am I handing the list correctly in the class?
I want to utilize the
__str__method so I can just print(object). How can I do this correctly?- I intend to use 2 instances of this class because I will be doing 2 separate sss.exec_command(command). Am I wasting memory by wrapping this function in a class? I wanted to utilize the OO to be efficient, organized, and try to utilize python's OO features.
class read_log:
def __init__(self, exit_status, *tuple_list):
self.exit_status = exit_status
self.tuple_list = tuple_list
if exit_status:
output = stderr.readlines()
else:
output = stdout.readlines()
del output[0]
del output[-1]
def __str__(self)
return ''.join(output)
def create():
stdin, stdout, stderr=ssh.exec_command("/home/one/script.sh")
exit_status = stdout.channel.recv_exit_status()
x = readlog(exit_status, stdin, stdout, stderr)
print(x)