From 9f32be83a6f14bd1181b667e2f0f8b1542e0af94 Mon Sep 17 00:00:00 2001 From: changzhi1990 Date: Fri, 15 Jan 2016 15:35:53 +0800 Subject: [PATCH] Fix unit test error --- stetho/agent/drivers/iperf.py | 4 ++-- stetho/stethoclient/agent_api.py | 11 ++++++++++- stetho/stethoclient/drivers/iperf_api.py | 10 +++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/stetho/agent/drivers/iperf.py b/stetho/agent/drivers/iperf.py index 6cacd5f..55c27d7 100644 --- a/stetho/agent/drivers/iperf.py +++ b/stetho/agent/drivers/iperf.py @@ -60,8 +60,8 @@ def start_client(self, host, port=5001, protocol='TCP', timeout=5, out_dict.pop() out_data = out_dict[-1].split() data = dict() - data['Bandwidth'] = out_data[-2] + out_data[-1] - data['Transfer'] = out_data[-4] + out_data[-3] + data['Bandwidth'] = out_data[-2] + ' ' + out_data[-1] + data['Transfer'] = out_data[-4] + ' ' + out_data[-3] data['Interval'] = out_data[-6] return data raise Exception('Start iperf failed, please check on the node.') diff --git a/stetho/stethoclient/agent_api.py b/stetho/stethoclient/agent_api.py index 14166da..78903a5 100644 --- a/stetho/stethoclient/agent_api.py +++ b/stetho/stethoclient/agent_api.py @@ -21,7 +21,6 @@ from cliff.command import Command from cliff.lister import Lister from json import JSONDecoder -from stetho.stethoclient.constants import AGENT_INFOS LISTEN_PORT = 9698 SETUP_LINK_IP_PRE = "192.168.100." @@ -48,6 +47,16 @@ def log_fail(info): print Logger.FAIL + info + Logger.ENDC +try: + from stetho.stethoclient.constants import AGENT_INFOS +except: + AGENT_INFOS = { + 'agent-64': "127.0.0.1", + 'agent-65': "127.0.0.1", + } + Logger.log_fail("Import stetho configure file fail. Use fake data!") + + def setup_server(agent): log = logging.getLogger(__name__) if agent in AGENT_INFOS: diff --git a/stetho/stethoclient/drivers/iperf_api.py b/stetho/stethoclient/drivers/iperf_api.py index a212608..558b523 100644 --- a/stetho/stethoclient/drivers/iperf_api.py +++ b/stetho/stethoclient/drivers/iperf_api.py @@ -20,7 +20,6 @@ import sys from cliff.lister import Lister -from stetho.stethoclient.constants import AGENT_INFOS LISTEN_PORT = 9698 @@ -45,6 +44,15 @@ def log_high(info): def log_fail(info): print Logger.FAIL + info + Logger.ENDC +try: + from stetho.stethoclient.constants import AGENT_INFOS +except: + AGENT_INFOS = { + 'agent-64': "127.0.0.1", + 'agent-65': "127.0.0.1", + } + Logger.log_fail("Import stetho configure file fail. Use fake data!") + def setup_server(agent): log = logging.getLogger(__name__)