fence_vmware_soap UnicodeEncodeError

执行如下命令

fence_vmware_soap -z -l administrator@vsphere.local -p 2wsx@QAZ -a 10.0.2.200 -o list --ssl-insecure | grep GFSCluster

Traceback (most recent call last):
  File "/usr/sbin/fence_vmware_soap", line 256, in <module>
    main()
  File "/usr/sbin/fence_vmware_soap", line 250, in main
    result = fence_action(conn_global, options_global, set_power_status, get_power_status, get_power_status)
  File "/usr/share/fence/fencing.py", line 872, in fence_action
    print(outlet_id + options["--separator"] + alias)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 10-11: ordinal not in range(128)

解决方案:

# encoding: utf-8
import codecs

并在840行的fence_action开头加入下面内容。
if sys.stdout.encoding != 'UTF-8':
    sys.stdout = codecs.getwriter('utf-8')(sys.stdout, 'strict')
if sys.stderr.encoding != 'UTF-8':
   sys.stderr = codecs.getwriter('utf-8')(sys.stderr, 'strict')

 

上一篇:python发起请求提示UnicodeEncodeError


下一篇:ECMAScript简介