【问题标题】:Capture just version from tox commands仅从 tox 命令捕获版本
【发布时间】:2019-01-02 11:35:39
【问题描述】:

我的 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),这是最优雅/pythonic 的方式干吗?还有无论如何我可以让 tox 只将输出输出到命令而不是其余的吗?

【问题讨论】:

    标签: python bash shell sed tox


    【解决方案1】:

    tox 命令中包含-qq 应该会将输出减少到仅0.2.0

    【讨论】:

    • 仍然打印:➜ oktapod git:(master) ✗ tox -qq -e version 0.2.0 version: commands succeeded congratulations :)
    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-22
      • 2010-11-10
      • 1970-01-01
      • 1970-01-01
      • 2012-08-22
      • 2016-12-02
      • 2012-02-18
      • 1970-01-01
      相关资源
      最近更新 更多