salt error : "TypeError: coercing to Unicode: need string or buffer, bool found"

salt error : "TypeError: coercing to Unicode: need string or buffer, bool found"

运行 salt 命令出现以下错误: 盐“”state.sls 出口工作

有人可以帮助解决这个问题吗?

  Function: pkg.installed
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1745, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1702, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/states/pkg.py", line 1442, in installed
                  **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/modules/aptpkg.py", line 637, in install
                  deb_info = __salt__['lowpkg.bin_pkg_info'](pkg_source)
                File "/usr/lib/python2.7/dist-packages/salt/modules/dpkg.py", line 67, in bin_pkg_info
                  if not os.path.exists(path):
                File "/usr/lib/python2.7/genericpath.py", line 18, in exists
                  os.stat(path)
              TypeError: coercing to Unicode: need string or buffer, bool found
     Started: 08:29:27.066443
    Duration: 39.616 ms
     Changes:

检查此页面 --> https://github.com/saltstack/salt/issues/12400。他们在谈论类似的问题。

Salt 不会抛出适当的错误消息,这就是所有混乱的原因。在我的例子中,data.sls 有一个包名称条目,该条目已被另一个 salt 脚本从 运行 此脚本之前的位置删除。

每当您收到此错误时,给定路径中应该缺少 file/directory。

如果 salt 抛出带有准确消息的错误,那就太好了。

在我的例子中,我打印了多个 table 的值。在第一个 table 中,它具有以下架构:

| ORDINAL_POSITION | COLUMN_NAME   | DATA_TYPE | CHARACTER_MAXIMUM_LENGTH | IS_NULLABLE |
|                1 | DateTimeStamp | datetime  | NULL                     | NO          |
|                2 | DataVal       | nvarchar  | -1                       | NO          |

这些打印没有问题。然后在第二个 table 中,它有这个架构:

| ORDINAL_POSITION | COLUMN_NAME   | DATA_TYPE | CHARACTER_MAXIMUM_LENGTH | IS_NULLABLE |
|                1 | DateTimeStamp | datetime  | NULL                     | NO          |
|                2 | DataVal       | bit       | NULL                     | NO          |

一旦到达第二个 table 的打印行,它就会抛出这个 coercing to Unicode: need string or buffer, bool found error:

        for myValue in tableValues:
            print str(myValue.dateTimeStamp)+', '+myValue.dataVal

所以为了避免这种情况,我只是将所有值都转换为字符串:

        for myValue in tableValues:
            print str(myValue.dateTimeStamp)+', '+str(myValue.dataVal)