summaryrefslogtreecommitdiffstats
path: root/tests/common
diff options
context:
space:
mode:
authordongwenjuan <dong.wenjuan@zte.com.cn>2017-08-28 17:14:03 +0800
committerdongwenjuan <dong.wenjuan@zte.com.cn>2017-09-04 22:33:47 +0800
commit1c1d3d1ddc21ae28deabef9f5f6e310d46fdf0ef (patch)
tree208f09c7d474c910961068e8a8bc09dae1eb9946 /tests/common
parent19f7ba75850c52e1ae163766b64b6d153e8d7e1b (diff)
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 <dong.wenjuan@zte.com.cn>
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common/utils.py14
1 files changed, 14 insertions, 0 deletions
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,