Moler 是为构建自动化测试提供“砖块”的 Python 库。 所有这些“砖头”都有明确的责任,有类似的API,遵循相同的构造模式(所以很容易创建新的测试)。
功能:
使用示例:
查找所有python进程的PID
from moler.config import load_config from moler.device.device import DeviceFactory load_config(config='my_devices.yml') # description of available devices my_unix = DeviceFactory.get_device(name='MyMachine') # take specific device out of available ones ps_cmd = my_unix.get_cmd(cmd_name="ps", # take command of that device cmd_params={"options": "-ef"}) processes_info = ps_cmd() # run the command, it returns result for proc_info in processes_info: if 'python' in proc_info['CMD']: print("PID: {info[PID]} CMD: {info[CMD]}".format(info=proc_info))
上述代码执行结果:
PID: 1817 CMD: /usr/bin/python /usr/share/system-config-printer/applet.py PID: 21825 CMD: /usr/bin/python /home/gl/moler/examples/command/unix_ps.py