需要重定向Python中的警告检查输出

2024-10-02 10:19:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我在使用check\ u output函数时收到警告,无法重定向警告。我想stderr只会接受错误和错误子流程检查输出无法处理警告(但不确定)。有人能建议吗?你知道吗

def getSnapshot(volumeName):
    try:

        snapID, snapAttach = check_output(["openstack", "volume", "snapshot", "list", "--volume", volumeName, "-c", "Name", "-c", "ID", "-f", "value"]).rstrip().split()
        myDict['snapshot'] = [snapAttach, snapID]
    except ValueError:
        myDict['snapshot'] = None
    return myDict

警告类型:

WARNING: openstackclient.common.utils is deprecated and will be removed after Jun 2017. Please use osc_lib.utils. This warning is caused by an out-of-date import in /usr/local/lib/python2.7/dist-packages/heatclient/osc/plugin.py\nIgnoring domain related config project_domain_id because identity API version is 2.0\n

Tags: 警告outputisdomainlibcheck错误snapshot

热门问题