From 86df512b76e52abee802bff901e562a8fd3a4883 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 1 Dec 2021 13:28:28 +0200 Subject: [PATCH] Refactor: Extract specdump to a function --- check-unused-files.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/check-unused-files.py b/check-unused-files.py index 4ecc6a9..e9edd05 100755 --- a/check-unused-files.py +++ b/check-unused-files.py @@ -5,6 +5,12 @@ import sys import os import fnmatch +def specdump(spec): + p = subprocess.Popen(['rpm-specdump', spec], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (out, err) = p.communicate(None) + p.wait() + return (out, err) + if len(sys.argv) == 2: spec = sys.argv[1] else: @@ -19,9 +25,7 @@ dir = os.path.dirname(spec) if dir == '': dir = '.' -p = subprocess.Popen(['rpm-specdump', spec], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) -(out, err) = p.communicate(None) -p.wait() +(out, err) = specdump(spec) if err: print >> sys.stderr, "%s: %s" % (sys.argv[0], err) sys.exit(1) -- 2.44.0