class ObjectConnection: def __init__(self): self.RUN_OK = 0 self.RUN_ERROR = 1 self.QUIT = True self.olt = None self.brand = None self.model = None self.hostname = None self.user = None self.password = None self.password_enable = None self.port = None self.file_name = None self.file_name_log = None self.file_name_exec = None self.data = None self.all_data = "" self.NEW_LINE_UNIX = '\n' self.NEW_LINE_WINDOWS = '\r\n' def initialize(self, brand, model, hostname, user, password, password_enable, port, file_name, data): """ Initialize all properties :param brand: :param model: :param hostname: :param user: :param password: :param password_enable: :param port: :param file_name: :param data: :return: """ self.brand = brand self.model = model self.hostname = hostname self.user = user self.password = password self.password_enable = password_enable self.port = port self.file_name = file_name self.data = data if file_name is not None: fl = file_name.split(".") fl.pop() self.file_name_log = ".".join(fl) + ".log" if file_name is not None: fl = file_name.split(".") fl.pop() self.file_name_exec = ".".join(fl) + ".exec" def save_log(self): """ Save all data in log """ if self.file_name_log: f = open(self.file_name_log, "w+") f.write(self.all_data) f.close() self.check_error_log() def check_error_log(self): """ Check if scripts produce error """ if self.olt.get_character_error() in self.all_data: self.RUN_OK = 1 f = open(self.file_name_exec, "w+") f.write(str(self.RUN_OK)) f.close() def command_print(self, command): """ Print command :param command: """ print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + command)