How to store the output of Yardstick command in Python variable?

53 Views Asked by At

I have written the below script to store the output of yardstick command into a variable(output) and display the value of variable.

The script is executing fine and the results are displayed in the console. After executing the script, I want to store the below details into a variable.But the below log details are not stored into output variable. Please help me to solve this issue?

Note: I am able to get the output of unix command into the output variable. Who, ls -ltr etc., Operating system: Ubuntu Programming language: Python Yardstick command to execute the opnfv test case. Code:

from time import sleep

import sys

import os

import subprocess

import pexpect

import time



script_exec_cmd="yardstick -d task start /home/test_cases/opnfv_yardstick_tc002.yaml"

output = subprocess.check_output(script_exec_cmd, shell=True)

sleep(100)

print '********************************'

print "output === >>" + output

print '****************************'

Information from console is mentioned below

2020-03-16 12:22:11,895 [DEBUG] yardstick.benchmark.runners.duration duration.py:124 queue.qsize() = 1

2020-03-16 12:22:11,895 [DEBUG] yardstick.benchmark.runners.duration duration.py:125 output_queue.qsize() = 0

2020-03-16 12:22:11,919 [DEBUG] yardstick.benchmark.runners.base base.py:282 result_queue size 1

2020-03-16 12:22:11,919 [INFO] yardstick.benchmark.core.task task.py:285 Runner ended

2020-03-16 12:22:11,920 [INFO] yardstick.benchmark.core.task task.py:129 Testcase: "opnfv_yardstick_tc002" SUCCESS!!!

2020-03-16 12:22:11,920 [INFO] yardstick.benchmark.contexts.heat heat.py:472 Undeploying context 'demo-b1a42587' START

2020-03-16 12:22:53,560 [INFO] yardstick.benchmark.contexts.heat heat.py:475 Undeploying context 'demo-b1a42587' DONE

2020-03-16 12:22:53,560 [INFO] yardstick.benchmark.core.task task.py:148 Task /home/ test_cases/opnfv_yardstick_tc002.yaml finished in 242 secs

2020-03-16 12:22:53,565 [INFO] yardstick.benchmark.core.task task.py:169 Report can be found in '/tmp/report.html'

2020-03-16 12:22:53,566 [INFO] yardstick.benchmark.core.task task.py:157 Total finished in 242 secs

2020-03-16 12:22:53,566 [INFO] yardstick.benchmark.core.task task.py:160 To generate report, execute command "yardstick report generate b1a42587-2285-4bb4-9805-e1e6bcebcc11 <YAML_NAME>"

2020-03-16 12:22:53,566 [INFO] yardstick.benchmark.core.task task.py:161 Task ALL DONE, exiting

2020-03-16 12:22:53,566 [INFO] yardstick.cmd.commands.task task.py:61 Task SUCCESS

2020-03-16 12:22:53,567 [DEBUG] yardstick.benchmark.runners.base base.py:147 Terminating all runners

********************************

output === >> Writing /home/yardstick/resources/files/yardstick_key-demo-b1a42587 ...



****************************
0

There are 0 best solutions below