Skip to content

Commit

Permalink
fixed redirecting command output to null
Browse files Browse the repository at this point in the history
did not test the last commit, sorry.
  • Loading branch information
cpbills committed May 7, 2013
1 parent 8769466 commit 91c389d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions blueprint/backend/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Search for `apt` packages to include in the blueprint.
"""

import os
import logging
import subprocess

Expand All @@ -16,16 +17,17 @@ def apt(b, r):

# try running dpkg --print-foreign-architectures to see if dpkg is
# multi-arch aware. if not, revert to old style output_format
rv = subprocess.call(['dpkg', '--print-foreign-architectures'],
stdout=FNULL, stderr=subprocess.STDOUT)
if rv != 0:
output_format = '${Status}\x1E${Package}\x1E${Version}\n'
with open(os.devnull, 'w') as fnull:
rv = subprocess.call(['dpkg', '--print-foreign-architectures'],
stdout = fnull, stderr = fnull)
if rv != 0:
output_format = '${Status}\x1E${Package}\x1E${Version}\n'

# Try for the full list of packages. If this fails, don't even
# bother with the rest because this is probably a Yum/RPM-based
# system.
try:
p = subprocess.Popen(['dpkg-query','-Wf',output_format],
p = subprocess.Popen(['dpkg-query','-Wf', output_format],
close_fds=True, stdout=subprocess.PIPE)
except OSError:
return
Expand Down

0 comments on commit 91c389d

Please sign in to comment.