def get_current_running_gx_process(self): """ Makes an attempt to retrieve currently running version. If nothing runs, None is returned. None value needs to be handled higher up. :return: """ # reset pexpect buffer rand_str = StringMethods.get_unique_string() self.shell.send_cmd(rand_str, expected_value=rand_str) # reset pexpect buffer location self.shell.send_cmd('initctl list | grep corero | grep running') index = self.shell.cli.expect(['(corero/defense-V\d.\d\d.\d.\d*_PGO)', pexpect.TIMEOUT]) if index == 0: running_version = self.shell.cli.after PrintMessage('Running GX version found: {0}'.format(running_version)) return running_version else: PrintMessage('Running no GX version.') return None
def get_current_running_ntd1100_process(self): """ Makes an attempt to retrieve currently running version. If nothing runs, None is returned. None value needs to be handled higher up. :return: """ # reset pexpect buffer rand_str = StringMethods.get_unique_string() self.shell.send_cmd( rand_str, expected_value=rand_str) # reset pexpect buffer location self.shell.send_cmd('initctl list | grep corero | grep running') index = self.shell.cli.expect( [DepConst.iNTD_VERSION_RE_EXPECT, pexpect.TIMEOUT]) if index == 0: running_version = self.shell.cli.after PrintMessage( 'Running iNTD version found: {0}'.format(running_version)) return running_version else: return None
def get_lines(cli, limit=None, terminating_value=None, set_buffer_tag=False): """ Reads all the content from pexpect buffer and returns is back to the caller. Assumes all data searched for is already printed out to the output. :param set_buffer_tag: :param terminating_value: :param cli: pexpect handler to cli :param limit: value to determine amount of data read, soft stop :return: """ PrintMessage('get_lines executed') if set_buffer_tag: terminating_value = StringMethods.get_unique_string() cli.sendline(terminating_value) line_count = 0 lines = [] try: while True: line = cli.readline() stripped = line.rstrip() if terminating_value and terminating_value in stripped: break if len(stripped) > 0: lines.append(stripped) line_count += 1 if limit and line_count >= limit: break return lines except pexpect.TIMEOUT: display_before_n_after(cli) return lines
def _create_temp_folder(): temp_folder = "/tmp/vm_unpacking_automation/{0}/".format( StringMethods.get_unique_string()) PrintMessage("Create temp folder in: {0}".format(temp_folder)) return DiskTools.create_folder(temp_folder)
def get_screenshot_name(self, failure_type): return SCREENSHOT_NAME.format( SCREENSHOTS_FOLDER, self.test_case._testMethodName, StringMethods.get_unique_string(failure_type))