From d6ebc7d19a510b3facf0209a218bfd5254ba8f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org> Date: Sat, 17 Jul 2010 19:02:49 +0200 Subject: [PATCH] pyclean, pycompile: use .communicate() instead of .wait() to avoid hanging `dpkg -L PACKAGE` in few situations --- debian/changelog | 7 +++++++ pyclean | 9 +++++---- pycompile | 9 +++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 115ea50..23578ee 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-defaults (2.6.5-9) UNRELEASED; urgency=low + + * pyclean, pycompile: use .communicate() instead of .wait() to avoid hanging + `dpkg -L PACKAGE` in few situations + + -- Piotr Ożarowski <piotr@debian.org> Sat, 17 Jul 2010 18:58:23 +0200 + python-defaults (2.6.5-8) unstable; urgency=low * Revert: diff --git a/pyclean b/pyclean index b3fe738..c13fcb1 100755 --- a/pyclean +++ b/pyclean @@ -85,12 +85,13 @@ def get_files(items): def get_package_files(package_name): - process = Popen("/usr/bin/dpkg -L %s" % package_name, shell=True, \ - stdout=PIPE, stderr=PIPE) - if process.wait() != 0: + process = Popen("/usr/bin/dpkg -L %s" % package_name,\ + shell=True, stdout=PIPE) + stdout, stderr = process.communicate() + if process.returncode != 0: log.error('cannot get content of %s', package_name) sys.exit(2) - for line in process.stdout: + for line in stdout: line = line.strip('\n') if line.endswith('.py'): yield line diff --git a/pycompile b/pycompile index 249ce5f..ba618cf 100755 --- a/pycompile +++ b/pycompile @@ -68,12 +68,13 @@ def get_directory_files(dname): def get_package_files(package_name): """Generate *.py file names available in given package.""" - process = Popen("/usr/bin/dpkg -L %s" % package_name, shell=True, \ - stdout=PIPE, stderr=PIPE) - if process.wait() != 0: + process = Popen("/usr/bin/dpkg -L %s" % package_name,\ + shell=True, stdout=PIPE) + stdout, stderr = process.communicate() + if process.returncode != 0: log.error('cannot get content of %s', package_name) exit(2) - for line in process.stdout: + for line in stdout: line = line.strip('\n') if line.endswith('.py'): yield line -- GitLab