summaryrefslogtreecommitdiffstats
path: root/tests/common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common/utils.py')
-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,