本文整理汇总了Python中Tools.Tools.find_cmd方法的典型用法代码示例。如果您正苦于以下问题:Python Tools.find_cmd方法的具体用法?Python Tools.find_cmd怎么用?Python Tools.find_cmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools.Tools
的用法示例。
在下文中一共展示了Tools.find_cmd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import find_cmd [as 别名]
class Connmon:
def __init__(self, config):
self.logger = logging.getLogger('browbeat.Connmon')
self.config = config
self.tools = Tools(self.config)
return None
# Start connmond
def start_connmon(self, retry=None):
self.stop_connmon()
tool = "connmond"
connmond = self.tools.find_cmd(tool)
if not connmond:
self.logger.error("Unable to find {}".format(tool))
as_sudo = self.config['connmon']['sudo']
cmd = ""
if as_sudo:
cmd += "sudo "
cmd += "screen -X -S connmond kill"
self.tools.run_cmd(cmd)
self.logger.info("Starting connmond")
cmd = ""
cmd += "{} --config /etc/connmon.cfg > /tmp/connmond 2>&1 &".format(
connmond)
self.tools.run_cmd(cmd)
if self.check_connmon_results is False:
if retry is None:
self.start_connmon(retry=True)
else:
return False
else:
return True
def check_connmon_results(self, result_file='/tmp/connmon_results.csv'):
return os.path.isfile(result_file)
# Stop connmond
def stop_connmon(self):
self.logger.info("Stopping connmond")
return self.tools.run_cmd("pkill -9 connmond")
# Create Connmon graphs
def connmon_graphs(self, result_dir, test_name):
cmd = "python graphing/connmonplot.py {}/connmon/{}.csv".format(result_dir,
test_name)
return self.tools.run_cmd(cmd)
# Move connmon results
def move_connmon_results(self, result_dir, test_name):
path = "%s/connmon" % result_dir
if not os.path.exists(path):
os.mkdir(path)
return shutil.move("/tmp/connmon_results.csv",
"{}/connmon/{}.csv".format(result_dir, test_name))