Merge "Test port data plane status on Sample Inspector"
[doctor.git] / tests / utils.py
index f57cd26..fd8c4cd 100644 (file)
@@ -56,7 +56,7 @@ class SSHClient(object):
         ret = stdout.channel.recv_exit_status()
         output = list()
         for line in stdout.read().splitlines():
-            output.append(line)
+            output.append(line.decode('utf-8'))
         if ret:
             if self.log:
                 self.log.debug("*** FAILED to run command %s (%s)" % (command, ret))
@@ -76,3 +76,15 @@ class SSHClient(object):
         elif method == 'get':
             ftp.get(source, dest)
         ftp.close()
+
+def run_async(func):
+    from threading import Thread
+    from functools import wraps
+
+    @wraps(func)
+    def async_func(*args, **kwargs):
+        thread = Thread(target=func, args=args, kwargs=kwargs)
+        thread.start()
+        return thread
+
+    return async_func