forked from pool/python-delegator.py
- Normalize metadata directory name.
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-delegator.py?expand=0&rev=11
This commit is contained in:
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
## Default LFS
|
||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.png filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.osc
|
||||||
3
delegator.py-0.1.1.tar.gz
Normal file
3
delegator.py-0.1.1.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:e6cc9cedab9ae59b169ee0422e17231adedadb144e63c0b5a60e6ff8adf8521b
|
||||||
|
size 6260
|
||||||
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
|
||||||
|
|
||||||
25
python-delegator.py.changes
Normal file
25
python-delegator.py.changes
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Mar 27 04:03:17 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
|
||||||
|
|
||||||
|
- Normalize metadata directory name.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Feb 29 03:13:06 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
|
||||||
|
|
||||||
|
- Switch to autosetup and pyproject macros.
|
||||||
|
- No more greedy globs in %files.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
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>
|
||||||
|
|
||||||
|
- Replace useless descriptions.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Mar 7 08:26:37 AM UTC 2019 - John Vandenberg <jayvdb@gmail.com>
|
||||||
|
|
||||||
|
- Initial spec for v0.1.1, using exclude-eof-from-result.patch
|
||||||
69
python-delegator.py.spec
Normal file
69
python-delegator.py.spec
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#
|
||||||
|
# spec file for package python-delegator.py
|
||||||
|
#
|
||||||
|
# Copyright (c) 2025 SUSE LLC
|
||||||
|
#
|
||||||
|
# All modifications and additions to the file contributed by third parties
|
||||||
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
|
# upon. The license for this file, and modifications and additions to the
|
||||||
|
# file, is the same license as for the pristine package itself (unless the
|
||||||
|
# license for the pristine package is not an Open Source License, in which
|
||||||
|
# case the license is the MIT License). An "Open Source License" is a
|
||||||
|
# license that conforms to the Open Source Definition (Version 1.9)
|
||||||
|
# published by the Open Source Initiative.
|
||||||
|
|
||||||
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
Name: python-delegator.py
|
||||||
|
Version: 0.1.1
|
||||||
|
Release: 0
|
||||||
|
Summary: Python library for dealing with subprocesses
|
||||||
|
License: MIT
|
||||||
|
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: merged_pr_62.patch
|
||||||
|
BuildRequires: %{python_module pexpect >= 4.1.0}
|
||||||
|
BuildRequires: %{python_module pip}
|
||||||
|
BuildRequires: %{python_module pytest}
|
||||||
|
BuildRequires: %{python_module setuptools}
|
||||||
|
BuildRequires: %{python_module wheel}
|
||||||
|
BuildRequires: fdupes
|
||||||
|
BuildRequires: python-rpm-macros
|
||||||
|
Requires: python-pexpect >= 4.1.0
|
||||||
|
BuildArch: noarch
|
||||||
|
Conflicts: python-delegator
|
||||||
|
|
||||||
|
%python_subpackages
|
||||||
|
|
||||||
|
%description
|
||||||
|
Delegator.py is a library for dealing with subprocesses, inspired
|
||||||
|
by both "envoy" and "pexpect" (in fact, it depends on it).
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%autosetup -p1 -n delegator.py-%{version}
|
||||||
|
cp %{SOURCE1} .
|
||||||
|
|
||||||
|
%build
|
||||||
|
%pyproject_wheel
|
||||||
|
|
||||||
|
%install
|
||||||
|
%pyproject_install
|
||||||
|
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||||
|
|
||||||
|
# Tests from master are not compatible. Likely fixed in next release.
|
||||||
|
# https://github.com/kennethreitz/delegator.py/pull/71
|
||||||
|
#%%check
|
||||||
|
#export PYTHONPATH=${PWD}
|
||||||
|
#%%python_exec -m pytest test_chain.py
|
||||||
|
|
||||||
|
%files %{python_files}
|
||||||
|
%doc README.rst
|
||||||
|
%license LICENSE
|
||||||
|
%{python_sitelib}/delegator.py
|
||||||
|
%pycache_only %{python_sitelib}/__pycache__/delegator.*.pyc
|
||||||
|
%{python_sitelib}/delegator_py-%{version}.dist-info
|
||||||
|
|
||||||
|
%changelog
|
||||||
6
test_chain.py
Normal file
6
test_chain.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import pytest
|
||||||
|
import delegator
|
||||||
|
|
||||||
|
def test_chain():
|
||||||
|
c = delegator.chain("seq 4 | awk '{ print $0 \" test\"; }'")
|
||||||
|
assert c.out == '1 test\n2 test\n3 test\n4 test\n'
|
||||||
Reference in New Issue
Block a user