盐错误:“TypeError:强制转换为Unicode:需要字符串或缓冲区,找到bool”

时间:2017-06-29 08:51:34

标签: devops salt-stack

运行salt命令时出现以下错误: salt“”state.sls export-job

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

  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:

3 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:0)

Salt不会抛出相应的错误消息,这就是为什么所有的混乱。在我的情况下,data.sls有一个包名称的条目,该名称在由另一个盐脚本运行此脚本之前从该位置删除。

每当出现此错误时,应该会丢失给定路径中的文件/目录。

如果盐因精确信息而引发错误,那就太好了。

答案 2 :(得分:0)

就我而言,我正在从多个表中打印值。在第一个表中,它具有以下架构:

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

这些打印没有问题。然后在第二张表中,它具有以下模式:

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

第二张表到达打印行时,它就抛出了这个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)