【发布时间】:2015-12-18 17:21:46
【问题描述】:
目前,我有一个类似于以下内容的命令:
my_command = Popen([activate_this_python_virtualenv_file, \
"-m", "my_command", "-l", \
directory_where_ini_file_for_my_command_is + "/" + my_ini_file_name], \
stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=False,
universal_newlines=False, cwd=directory_where_my_module_is)
我已经弄清楚如何访问和处理输出,处理subprocess.PIPE,并让 subprocess 做一些其他巧妙的技巧。
但是,the standard Python documentation for subprocess 没有提到获取实际命令行的方法,因为 subprocess.Popen 将其从参数组合到 Popen 构造函数中,这对我来说似乎很奇怪。
例如,可能是my_command.get_args() 或类似的东西?
只是在Popen 中运行命令行应该很容易吗?
我可以自己将参数放在一起,而无需访问命令subprocess 与Popen 一起运行,但如果有更好的方法,我想知道。
【问题讨论】:
标签: linux python-3.x subprocess popen