从tox命令仅捕获版本

时间:2018-07-25 15:17:32

标签: python bash shell sed tox

我的tox.ini中有以下内容:

[tox]
skipsdist = true
envlist = py27, py36, lint

[testenv]
whitelist_externals=flake8
commands =
    version: python setup.py --version

我跑步时

  

tox -e版本

我得到以下输出:

tox -e version 2>version
version runtests: PYTHONHASHSEED='3264081464'
version runtests: commands[0] | python setup.py --version
0.2.0
__________________________________________________________________________________________________________________________________________________________ summary ___________________________________________________________________________________________________________________________________________________________
  version: commands succeeded
  congratulations :)

我只需要从 tox -e version 输出中捕获版本( 0.2.0 ),这是最优雅/ Python方式这样做吗?此外,无论如何,我只能将输出输出到命令,而不能将其余的命令输出到tox吗?

2 个答案:

答案 0 :(得分:2)

将版本保存到文件中。在tox.ini中:

[testenv]
whitelist_externals = /bin/sh
commands =
    version: /bin/sh -c "python setup.py --version >version"

在外壳中:

tox -e version
cat version
rm version

答案 1 :(得分:0)

.vimrc命令中包含-qq会使输出减少到tox