Skip to content

Commit 32b08d9

Browse files
committed
Merge pull request #130 from Shao-Feng/native
add checking for stable connection with stub
2 parents 555a29d + 0a62dd4 commit 32b08d9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

testkitlite/commodule/windowshttp.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,24 @@ def shell_cmd_ext(self,
194194
boutput=False,
195195
stdout_file=None,
196196
stderr_file=None):
197+
check_stub_num = 0
198+
while (not self.check_process("")) and check_stub_num < 3:
199+
self.launch_stub("")
200+
check_stub_num += 1
201+
time.sleep(3)
197202
cmd_json = {}
198203
cmd_json['cmd'] = cmd
199204
server_url = "http://%s:8000" % self.deviceip
200205
result = http_request(
201206
get_url(server_url, "/general_cmd_response"), "POST", cmd_json, 30)
202-
LOGGER.info("Response exit_code: %s" % result["exit_code"])
203-
LOGGER.info("Response output: %s" % result["output"])
204-
time.sleep(1)
205-
return [int(result["exit_code"]), result["output"], ""]
207+
if result is not None:
208+
LOGGER.info("Response exit_code: %s" % result["exit_code"])
209+
LOGGER.info("Response output: %s" % result["output"])
210+
time.sleep(1)
211+
return [int(result["exit_code"]), result["output"], []]
212+
else:
213+
LOGGER.info("Fail to connect stub!")
214+
return [-1, ["Fail to connect stub"], []]
206215

207216
######### commodule TC execution end #############
208217

0 commit comments

Comments
 (0)