diff options
| author | Julian Andres Klode <jak@debian.org> | 2012-06-25 14:26:43 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2012-06-25 14:26:43 +0200 |
| commit | f513760769e5e0c7ba08f171e4d5399000b8ae51 (patch) | |
| tree | 218bb7cfe1b83fbe5bcc9ff755af1ade2acae660 | |
| parent | b50494275b8235e5c8a53e13fd56e3cea1c8d5b3 (diff) | |
| download | python-apt-f513760769e5e0c7ba08f171e4d5399000b8ae51.tar.gz | |
Use Popen.communicate() instead of stdin, stdout
| -rw-r--r-- | apt/auth.py | 22 | ||||
| -rw-r--r-- | debian/changelog | 1 |
2 files changed, 13 insertions, 10 deletions
diff --git a/apt/auth.py b/apt/auth.py index 1a81d3b0..5d4b1cd6 100644 --- a/apt/auth.py +++ b/apt/auth.py @@ -70,17 +70,19 @@ def _call_apt_key_script(*args, **kwargs): stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - try: - proc.stdin.write(kwargs["stdin"]) - except KeyError: - pass - finally: - proc.stdin.close() - return_code = proc.wait() - output = proc.stdout.read() - if return_code: + + content = kwargs.get("stdin", None) + if isinstance(content, unicode): + content = content.encode("utf-8") + + output, stderr = proc.communicate(content) + + assert stderr == None + + if proc.returncode: raise SystemError("The apt-key script failed with return code %s:\n" - "%s\n%s" % (return_code, " ".join(cmd), output)) + "%s\n%s" % (proc.returncode, " ".join(cmd), + output)) return output.strip() finally: if conf is not None: diff --git a/debian/changelog b/debian/changelog index e6d6d648..627ef655 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,7 @@ python-apt (0.8.6) UNRELEASED; urgency=low [ Julian Andres Klode ] * apt/auth.py: - Use tempfile.NamedTemporaryFile to create temporary file + - Use Popen.communicate() instead of stdin, stdout -- Michael Vogt <mvo@debian.org> Mon, 25 Jun 2012 13:41:02 +0200 |
