- Fix encoding for pexpect with Python 3.6
Resolves: rhbz#1473908
This commit is contained in:
parent
b9bb33ba59
commit
0dc0af204c
89
bz1473908-fix-pexpect-encoding.patch
Normal file
89
bz1473908-fix-pexpect-encoding.patch
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
From 48c9a45ce3c2fbf40b087a581b4670f75df8f4c7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
||||||
|
Date: Thu, 27 Jul 2017 12:39:29 +0200
|
||||||
|
Subject: [PATCH] Fix encoding for pexpect with Python 3.6
|
||||||
|
|
||||||
|
---
|
||||||
|
fence/agents/lib/fencing.py.py | 15 +++++++++++++--
|
||||||
|
fence/agents/lib/fencing_snmp.py.py | 4 ++--
|
||||||
|
fence/agents/vmware/fence_vmware.py | 4 ++--
|
||||||
|
3 files changed, 17 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
|
||||||
|
index 4001787d..d2b7f033 100644
|
||||||
|
--- a/fence/agents/lib/fencing.py.py
|
||||||
|
+++ b/fence/agents/lib/fencing.py.py
|
||||||
|
@@ -472,9 +472,11 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
class fspawn(pexpect.spawn):
|
||||||
|
- def __init__(self, options, command):
|
||||||
|
+ def __init__(self, options, command, **kwargs):
|
||||||
|
+ if sys.version_info[0] > 2:
|
||||||
|
+ kwargs.setdefault('encoding', 'utf-8')
|
||||||
|
logging.info("Running command: %s", command)
|
||||||
|
- pexpect.spawn.__init__(self, command)
|
||||||
|
+ pexpect.spawn.__init__(self, command, **kwargs)
|
||||||
|
self.opt = options
|
||||||
|
|
||||||
|
def log_expect(self, pattern, timeout):
|
||||||
|
@@ -490,6 +492,15 @@ def send(self, message):
|
||||||
|
def send_eol(self, message):
|
||||||
|
return self.send(message + self.opt["eol"])
|
||||||
|
|
||||||
|
+def frun(command, timeout=30, withexitstatus=False, events=None,
|
||||||
|
+ extra_args=None, logfile=None, cwd=None, env=None, **kwargs):
|
||||||
|
+ if sys.version_info[0] > 2:
|
||||||
|
+ kwargs.setdefault('encoding', 'utf-8')
|
||||||
|
+ return pexpect.run(command, timeout=timeout,
|
||||||
|
+ withexitstatus=withexitstatus, events=events,
|
||||||
|
+ extra_args=extra_args, logfile=logfile, cwd=cwd,
|
||||||
|
+ env=env, **kwargs)
|
||||||
|
+
|
||||||
|
def atexit_handler():
|
||||||
|
try:
|
||||||
|
sys.stdout.close()
|
||||||
|
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
|
||||||
|
index 9aaf52be..6d9e2110 100644
|
||||||
|
--- a/fence/agents/lib/fencing_snmp.py.py
|
||||||
|
+++ b/fence/agents/lib/fencing_snmp.py.py
|
||||||
|
@@ -5,7 +5,7 @@
|
||||||
|
import re, pexpect
|
||||||
|
import logging
|
||||||
|
from fencing import *
|
||||||
|
-from fencing import fail, fail_usage, EC_TIMED_OUT, run_delay
|
||||||
|
+from fencing import fail, fail_usage, EC_TIMED_OUT, run_delay, frun
|
||||||
|
|
||||||
|
__all__ = ['FencingSnmp']
|
||||||
|
|
||||||
|
@@ -87,7 +87,7 @@ def run_command(self, command, additional_timemout=0):
|
||||||
|
try:
|
||||||
|
logging.debug("%s\n", command)
|
||||||
|
|
||||||
|
- (res_output, res_code) = pexpect.run(command,
|
||||||
|
+ (res_output, res_code) = frun(command,
|
||||||
|
int(self.options["--shell-timeout"]) +
|
||||||
|
int(self.options["--login-timeout"]) +
|
||||||
|
additional_timemout, True)
|
||||||
|
diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py
|
||||||
|
index 8bb061e4..6b60b5e5 100644
|
||||||
|
--- a/fence/agents/vmware/fence_vmware.py
|
||||||
|
+++ b/fence/agents/vmware/fence_vmware.py
|
||||||
|
@@ -27,7 +27,7 @@
|
||||||
|
import atexit
|
||||||
|
sys.path.append("@FENCEAGENTSLIBDIR@")
|
||||||
|
from fencing import *
|
||||||
|
-from fencing import fail, fail_usage, EC_TIMED_OUT, run_delay
|
||||||
|
+from fencing import fail, fail_usage, EC_TIMED_OUT, run_delay, frun
|
||||||
|
|
||||||
|
#BEGIN_VERSION_GENERATION
|
||||||
|
RELEASE_VERSION="VMware Agent using VI Perl API and/or VIX vmrun command"
|
||||||
|
@@ -146,7 +146,7 @@ def vmware_run_command(options, add_login_params, additional_params, additional_
|
||||||
|
try:
|
||||||
|
logging.debug("%s\n", command)
|
||||||
|
|
||||||
|
- (res_output, res_code) = pexpect.run(command,
|
||||||
|
+ (res_output, res_code) = frun(command,
|
||||||
|
int(options["--shell-timeout"]) + int(options["--login-timeout"]) + additional_timeout, True)
|
||||||
|
|
||||||
|
if res_code == None:
|
@ -16,12 +16,13 @@
|
|||||||
Name: fence-agents
|
Name: fence-agents
|
||||||
Summary: Fence Agents for Red Hat Cluster
|
Summary: Fence Agents for Red Hat Cluster
|
||||||
Version: 4.0.24
|
Version: 4.0.24
|
||||||
Release: 8%{?alphatag:.%{alphatag}}%{?dist}
|
Release: 9%{?alphatag:.%{alphatag}}%{?dist}
|
||||||
License: GPLv2+ and LGPLv2+
|
License: GPLv2+ and LGPLv2+
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
URL: http://sourceware.org/cluster/wiki/
|
URL: http://sourceware.org/cluster/wiki/
|
||||||
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.xz
|
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.xz
|
||||||
Patch0: python3.patch
|
Patch0: python3.patch
|
||||||
|
Patch1: bz1473908-fix-pexpect-encoding.patch
|
||||||
|
|
||||||
%if 0%{?fedora}
|
%if 0%{?fedora}
|
||||||
%global testagents zvm virsh raritan rcd_serial
|
%global testagents zvm virsh raritan rcd_serial
|
||||||
@ -777,6 +778,11 @@ The fence-agents-zvm package contains a fence agent for IBM z/VM over IP.
|
|||||||
%{_mandir}/man8/fence_zvmip.8*
|
%{_mandir}/man8/fence_zvmip.8*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Aug 3 2017 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.0.24-9
|
||||||
|
- Fix encoding for pexpect with Python 3.6
|
||||||
|
|
||||||
|
Resolves: rhbz#1473908
|
||||||
|
|
||||||
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.24-8
|
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.24-8
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user