我创建并安装了virutalenv。我还在我的virutal env中安装了jsnapy工具。如何使用Python在虚拟环境中运行命令
这是我们正在使用的脚本:
Filename : venv.py
import os
os.system('/bin/bash --rcfile ~/TestAutomation/End2EndAutomation/bin/activate')
os.system('End2EndAutomation/bin/jsnapy')
[email protected]:~/TestAutomation$ python venv.py
(End2EndAutomation) [email protected]:~/TestAutomation$ ^C
我们需要知道的,是我们如何能够进入virutalenv,运行一个命令,并使用python脚本停用?
[EDIT1]
我使用了评论中给出的代码。它刚刚进入虚拟环境。当我发出退出时,它运行jsnapy命令。
[email protected]:~/TestAutomation$ python venv.py
(End2EndAutomation) [email protected]:~/TestAutomation$ exit
exit
usage:
This tool enables you to capture and audit runtime environment of
networked devices running the Junos operating system (Junos OS)
Tool to capture snapshots and compare them
It supports four subcommands:
--snap, --check, --snapcheck, --diff
1. Take snapshot:
jsnapy --snap pre_snapfile -f main_configfil
它不调用jnapy直到我发出退出虚拟环境。有没有任何有效的方式来做这件事,而不是做一个系统调用。 – srinath
你需要添加更多关于这个问题的信息到你的问题。 – Soviut