forked from pool/python-delegator.py
Accepting request 1030587 from home:jayvdb:branches:devel:languages:python
- Replace custom exclude-eof-from-result.patch with merged_pr_62.patch OBS-URL: https://build.opensuse.org/request/show/1030587 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-delegator.py?expand=0&rev=7
This commit is contained in:
parent
a16c98f119
commit
9be0228ca4
@ -1,40 +0,0 @@
|
||||
--- delegator.py-0.1.1/delegator.py.orig 2018-09-18 02:35:34.000000000 +0700
|
||||
+++ delegator.py-0.1.1/delegator.py 2019-03-08 00:53:35.605573650 +0700
|
||||
@@ -7,6 +7,8 @@
|
||||
import errno
|
||||
|
||||
from pexpect.popen_spawn import PopenSpawn
|
||||
+import pexpect
|
||||
+pexpect.EOF.__module__ = "pexpect.exceptions"
|
||||
|
||||
# Include `unicode` in STR_TYPES for Python 2.X
|
||||
try:
|
||||
@@ -110,7 +112,7 @@
|
||||
if self.subprocess.before:
|
||||
result += self.subprocess.before
|
||||
|
||||
- if self.subprocess.after:
|
||||
+ if self.subprocess.after and self.subprocess.after is not pexpect.EOF:
|
||||
result += self.subprocess.after
|
||||
|
||||
result += self.subprocess.read()
|
||||
@@ -205,7 +207,10 @@
|
||||
if self.blocking:
|
||||
raise RuntimeError("expect can only be used on non-blocking commands.")
|
||||
|
||||
- self.subprocess.expect(pattern=pattern, timeout=timeout)
|
||||
+ try:
|
||||
+ self.subprocess.expect(pattern=pattern, timeout=timeout)
|
||||
+ except pexpect.EOF:
|
||||
+ pass
|
||||
|
||||
def send(self, s, end=os.linesep, signal=False):
|
||||
"""Sends the given string or signal to std_in."""
|
||||
@@ -263,7 +268,6 @@
|
||||
c.run(block=False, cwd=cwd)
|
||||
if data:
|
||||
c.send(data)
|
||||
- c.subprocess.sendeof()
|
||||
c.block()
|
||||
return c
|
||||
|
157
merged_pr_62.patch
Normal file
157
merged_pr_62.patch
Normal file
@ -0,0 +1,157 @@
|
||||
From 9bb7790d6ad54a238f57cce8ad93a811ef302268 Mon Sep 17 00:00:00 2001
|
||||
From: Dan Ryan <dan@danryan.co>
|
||||
Date: Mon, 22 Oct 2018 09:42:40 -0400
|
||||
Subject: [PATCH 1/3] Explicitly close file handles on block
|
||||
|
||||
- Fixes #61
|
||||
|
||||
Signed-off-by: Dan Ryan <dan@danryan.co>
|
||||
---
|
||||
delegator.py | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/delegator.py b/delegator.py
|
||||
index d15aeb9..9eb430d 100644
|
||||
--- a/delegator.py
|
||||
+++ b/delegator.py
|
||||
@@ -233,6 +233,8 @@ def kill(self):
|
||||
def block(self):
|
||||
"""Blocks until process is complete."""
|
||||
if self._uses_subprocess:
|
||||
+ # Close open file handles to prevent leaking them
|
||||
+ self.subprocess.stdout.close()
|
||||
# consume stdout and stderr
|
||||
try:
|
||||
stdout, stderr = self.subprocess.communicate()
|
||||
@@ -241,6 +243,8 @@ def block(self):
|
||||
except ValueError:
|
||||
pass # Don't read from finished subprocesses.
|
||||
else:
|
||||
+ self.subprocess.sendeof()
|
||||
+ self.subprocess.proc.stdout.close()
|
||||
self.subprocess.wait()
|
||||
|
||||
def pipe(self, command, timeout=None, cwd=None):
|
||||
|
||||
From eddd9d14e50f7945faf99cac92ef33ab18b1342b Mon Sep 17 00:00:00 2001
|
||||
From: Dan Ryan <dan@danryan.co>
|
||||
Date: Mon, 22 Oct 2018 10:04:15 -0400
|
||||
Subject: [PATCH 2/3] Don't pass `subprocess.PIPE` to blocking Popen calls
|
||||
|
||||
Signed-off-by: Dan Ryan <dan@danryan.co>
|
||||
---
|
||||
delegator.py | 23 ++++++++++++++---------
|
||||
1 file changed, 14 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/delegator.py b/delegator.py
|
||||
index 9eb430d..3ffb2e3 100644
|
||||
--- a/delegator.py
|
||||
+++ b/delegator.py
|
||||
@@ -178,6 +178,7 @@ def run(self, block=True, binary=False, cwd=None, env=None):
|
||||
# Use subprocess.
|
||||
if self.blocking:
|
||||
popen_kwargs = self._default_popen_kwargs.copy()
|
||||
+ del popen_kwargs["stdin"]
|
||||
popen_kwargs["universal_newlines"] = not binary
|
||||
if cwd:
|
||||
popen_kwargs["cwd"] = cwd
|
||||
@@ -233,19 +234,23 @@ def kill(self):
|
||||
def block(self):
|
||||
"""Blocks until process is complete."""
|
||||
if self._uses_subprocess:
|
||||
- # Close open file handles to prevent leaking them
|
||||
- self.subprocess.stdout.close()
|
||||
# consume stdout and stderr
|
||||
- try:
|
||||
- stdout, stderr = self.subprocess.communicate()
|
||||
- self.__out = stdout
|
||||
- self.__err = stderr
|
||||
- except ValueError:
|
||||
- pass # Don't read from finished subprocesses.
|
||||
+ if self.blocking:
|
||||
+ try:
|
||||
+ stdout, stderr = self.subprocess.communicate()
|
||||
+ self.__out = stdout
|
||||
+ self.__err = stderr
|
||||
+ except ValueError:
|
||||
+ pass # Don't read from finished subprocesses.
|
||||
+ else:
|
||||
+ self.subprocess.stdin.close()
|
||||
+ self.std_out.close()
|
||||
+ self.std_err.close()
|
||||
+ self.subprocess.wait()
|
||||
else:
|
||||
self.subprocess.sendeof()
|
||||
- self.subprocess.proc.stdout.close()
|
||||
self.subprocess.wait()
|
||||
+ self.subprocess.proc.stdout.close()
|
||||
|
||||
def pipe(self, command, timeout=None, cwd=None):
|
||||
"""Runs the current command and passes its output to the next
|
||||
|
||||
From d07d065ef3ae5f7b637214a9fe193a4c642126cb Mon Sep 17 00:00:00 2001
|
||||
From: Dan Ryan <dan@danryan.co>
|
||||
Date: Tue, 23 Oct 2018 18:53:27 -0400
|
||||
Subject: [PATCH 3/3] Don't pass `EOF` to the caller
|
||||
|
||||
Signed-off-by: Dan Ryan <dan@danryan.co>
|
||||
---
|
||||
delegator.py | 17 ++++++++++++-----
|
||||
1 file changed, 12 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/delegator.py b/delegator.py
|
||||
index 3ffb2e3..56d1245 100644
|
||||
--- a/delegator.py
|
||||
+++ b/delegator.py
|
||||
@@ -7,6 +7,8 @@
|
||||
import errno
|
||||
|
||||
from pexpect.popen_spawn import PopenSpawn
|
||||
+import pexpect
|
||||
+pexpect.EOF.__module__ = "pexpect.exceptions"
|
||||
|
||||
# Include `unicode` in STR_TYPES for Python 2.X
|
||||
try:
|
||||
@@ -110,7 +112,7 @@ def _pexpect_out(self):
|
||||
if self.subprocess.before:
|
||||
result += self.subprocess.before
|
||||
|
||||
- if self.subprocess.after:
|
||||
+ if self.subprocess.after and self.subprocess.after is not pexpect.EOF:
|
||||
result += self.subprocess.after
|
||||
|
||||
result += self.subprocess.read()
|
||||
@@ -206,7 +208,10 @@ def expect(self, pattern, timeout=-1):
|
||||
if self.blocking:
|
||||
raise RuntimeError("expect can only be used on non-blocking commands.")
|
||||
|
||||
- self.subprocess.expect(pattern=pattern, timeout=timeout)
|
||||
+ try:
|
||||
+ self.subprocess.expect(pattern=pattern, timeout=timeout)
|
||||
+ except pexpect.EOF:
|
||||
+ pass
|
||||
|
||||
def send(self, s, end=os.linesep, signal=False):
|
||||
"""Sends the given string or signal to std_in."""
|
||||
@@ -249,8 +254,11 @@ def block(self):
|
||||
self.subprocess.wait()
|
||||
else:
|
||||
self.subprocess.sendeof()
|
||||
- self.subprocess.wait()
|
||||
- self.subprocess.proc.stdout.close()
|
||||
+ try:
|
||||
+ self.subprocess.wait()
|
||||
+ finally:
|
||||
+ if self.subprocess.proc.stdout:
|
||||
+ self.subprocess.proc.stdout.close()
|
||||
|
||||
def pipe(self, command, timeout=None, cwd=None):
|
||||
"""Runs the current command and passes its output to the next
|
||||
@@ -272,7 +280,6 @@ def pipe(self, command, timeout=None, cwd=None):
|
||||
c.run(block=False, cwd=cwd)
|
||||
if data:
|
||||
c.send(data)
|
||||
- c.subprocess.sendeof()
|
||||
c.block()
|
||||
return c
|
||||
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Sun Oct 23 09:43:15 UTC 2022 - John Vandenberg <jayvdb@gmail.com>
|
||||
|
||||
- Replace custom exclude-eof-from-result.patch with merged_pr_62.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 15 18:51:31 UTC 2019 - Jan Engelhardt <jengelh@inai.de>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-delegator.py
|
||||
#
|
||||
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2022 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -23,10 +23,10 @@ Release: 0
|
||||
Summary: Python library for dealing with subprocesses
|
||||
License: MIT
|
||||
Group: Development/Languages/Python
|
||||
Url: https://github.com/kennethreitz/delegator.py
|
||||
URL: https://github.com/kennethreitz/delegator.py
|
||||
Source: https://files.pythonhosted.org/packages/source/d/delegator.py/delegator.py-%{version}.tar.gz
|
||||
Source1: https://raw.githubusercontent.com/kennethreitz/delegator.py/master/tests/test_chain.py
|
||||
Patch0: exclude-eof-from-result.patch
|
||||
Patch0: merged_pr_62.patch
|
||||
BuildRequires: %{python_module pexpect >= 4.1.0}
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
|
Loading…
Reference in New Issue
Block a user