From 1c1d3d1ddc21ae28deabef9f5f6e310d46fdf0ef Mon Sep 17 00:00:00 2001 From: dongwenjuan Date: Mon, 28 Aug 2017 17:14:03 +0800 Subject: add running profiler in python For support bash and python both, I don't refactor the profiler_poc file, just call the func in python main. JIRA: DOCTOR-117 Change-Id: I5f06ecbd673c6a21acc94cc359a3f2b749b77b13 Signed-off-by: dongwenjuan --- tests/common/utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/common') diff --git a/tests/common/utils.py b/tests/common/utils.py index 38fd97d8..2e823acb 100644 --- a/tests/common/utils.py +++ b/tests/common/utils.py @@ -9,6 +9,7 @@ import json import os import paramiko +import re def load_json_file(full_path): @@ -33,6 +34,19 @@ def write_json_file(full_path, data): file.write(json.dumps(data)) +def match_rep_in_file(regex, full_path): + if not os.path.isfile(full_path): + raise Exception('File(%s) does not exist' % full_path) + + with open(full_path, 'r') as file: + for line in file: + result = re.search(regex, line) + if result: + return result + + return None + + class SSHClient(object): def __init__(self, ip, username, password=None, pkey=None, key_filename=None, log=None, look_for_keys=False, -- cgit 1.2.3-korg