Replaced the print() outputs to the sys.stdout.write()
Change-Id: Ib6dad45ba72383e19a616ca5ed601fb38f0701ce
diff --git a/tests/test_glance.py b/tests/test_glance.py
index 460d900..99db954 100644
--- a/tests/test_glance.py
+++ b/tests/test_glance.py
@@ -1,8 +1,9 @@
-import pytest
-import time
-import subprocess
-import random
import logging
+import pytest
+import random
+import subprocess
+import sys
+import time
import utils
@@ -94,7 +95,7 @@
record_property("Upload", speed_upload)
record_property("Download", speed_download)
- print("++++++++++++++++++++++++++++++++++++++++")
- print(('upload - {} MB/s'.format(speed_upload)))
- print(('download - {} MB/s'.format(speed_download)))
- print("++++++++++++++++++++++++++++++++++++++++")
+ sys.stdout.write("\n++++++++++++++++++++++++++++++++++++++++")
+ sys.stdout.write(('\nupload - {} MB/s'.format(speed_upload)))
+ sys.stdout.write(('\ndownload - {} MB/s'.format(speed_download)))
+ sys.stdout.write("\n++++++++++++++++++++++++++++++++++++++++\n")
diff --git a/tests/test_vm2vm.py b/tests/test_vm2vm.py
index e60a7fd..4367ee8 100644
--- a/tests/test_vm2vm.py
+++ b/tests/test_vm2vm.py
@@ -1,4 +1,5 @@
import logging
+import sys
import time
import pytest
@@ -185,18 +186,17 @@
logger.info("Drawing the table with iperf results...")
result_table.add_rows(table_rows)
- print('\n{}'.format(result_table.draw()))
+ sys.stdout.write('\n{}\n'.format(result_table.draw()))
- print("Removing VMs and FIPs...")
logger.info("Removing VMs and FIPs...")
for vm in vms:
openstack_clients.compute.servers.delete(vm)
- print("Removing FIPs...")
+ logger.info("Removing FIPs...")
for fip in fips:
openstack_clients.compute.floating_ips.delete(fip)
except Exception as e:
- print(e)
- print("Something went wrong")
+ sys.stdout.write("\n{}".format(e))
+ sys.stdout.write("\nSomething went wrong\n")
if 'vms' in locals():
logger.info("Removing VMs...")
for vm in vms:
@@ -206,5 +206,5 @@
for fip in fips:
openstack_clients.compute.floating_ips.delete(fip)
else:
- print("Skipping cleaning, VMs were not created")
+ sys.stdout.write("\nSkipping cleaning, VMs were not created")
pytest.fail("Something went wrong")
diff --git a/utils/__init__.py b/utils/__init__.py
index 8e858b3..8b04bab 100644
--- a/utils/__init__.py
+++ b/utils/__init__.py
@@ -1,6 +1,7 @@
-import os
-import yaml
import logging
+import os
+import sys
+import yaml
from utils import os_client
@@ -22,8 +23,8 @@
cmp_hosts = config.get('CMP_HOSTS') or []
skipped_nodes = config.get('skipped_nodes') or []
if skipped_nodes:
- print(("\nNotice: {} nodes will be skipped for vm2vm test".format(
- ",".join(skipped_nodes))))
+ sys.stdout.write(("\nNotice: {} nodes will be skipped for vm2vm test"
+ "".format(",".join(skipped_nodes))))
logger.info("Skipping nodes {}".format(",".join(skipped_nodes)))
if not cmp_hosts:
openstack_clients = os_client.OfficialClientManager(
diff --git a/utils/helpers.py b/utils/helpers.py
index 800a9fe..add9e87 100644
--- a/utils/helpers.py
+++ b/utils/helpers.py
@@ -1,3 +1,5 @@
+import sys
+
import texttable as tt
@@ -21,4 +23,4 @@
for row in global_results:
tab.add_row(row)
s = tab.draw()
- print(s)
+ sys.stdout.write(s)
diff --git a/utils/os_client.py b/utils/os_client.py
index 8ef55de..e22ce19 100644
--- a/utils/os_client.py
+++ b/utils/os_client.py
@@ -1,3 +1,9 @@
+import logging
+import os
+import random
+import sys
+import time
+
from cinderclient import client as cinder_client
from glanceclient import client as glance_client
from keystoneauth1 import identity as keystone_identity
@@ -6,11 +12,6 @@
from neutronclient.v2_0 import client as neutron_client
from novaclient import client as novaclient
-import logging
-import os
-import random
-import time
-
import utils
logger = logging.getLogger(__name__)
@@ -64,7 +65,7 @@
tenant_name=None, auth_url=None, cert=None,
domain='Default'):
if None in (username, password, tenant_name):
- print((username, password, tenant_name))
+ sys.stdout.write((username, password, tenant_name))
msg = ("Missing required credentials for identity client. "
"username: {username}, password: {password}, "
"tenant_name: {tenant_name}").format(