Upload the contribution of vstf as bottleneck network framework.
[bottlenecks.git] / vstf / vstf / common / cmds.py
1 import commands
2 import logging
3
4 LOG = logging.getLogger(__name__)
5
6
7 def execute(cmd=None, care_result=True):
8     if not cmd:
9         LOG.error('The cmd is None')
10         return None
11     try:
12         (status, ret) = commands.getstatusoutput(cmd)
13         if care_result and 0 != status:
14             LOG.error('CMD<%(cmd)s> \nSTDOUT:\n%(ret)s.', {'cmd':cmd, 'ret':ret})
15             return None
16         else:
17             return ret
18     except Exception as e:
19         raise e