Use subprocess.DEVNULL in python scripts.

This commit is contained in:
Tim Waugh 2014-08-22 12:27:30 +01:00
parent ce129d3443
commit 71c633e3d9
2 changed files with 12 additions and 14 deletions

View File

@ -103,9 +103,9 @@ def get_driver_version():
def run_with_arg (arg):
try:
p = subprocess.Popen ([driver_bin, arg],
stdin=io.FileIO("/dev/null"),
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=io.FileIO("/dev/null", "w"),
stderr=subprocess.DEVNULL,
shell=False)
(stdout, stderr) = p.communicate ()
except OSError:
@ -612,8 +612,8 @@ def update_ppd (ppd_source_filename):
chcon = subprocess.Popen (["chcon", "--reference=%s" % ppd_dest_filename,
tmpnew], shell=False,
stdin=io.FileIO("/dev/null"),
stdout=io.FileIO("/dev/null", "w"),
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)
chcon.communicate ()
@ -771,8 +771,7 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
shell=False,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=io.FileIO("/dev/null",
"w"))
stderr=subprocess.DEVNULL)
server_multicat_initialized = mc_proc
print ("%s" % url, file=server_multicat_initialized.stdin)
@ -785,9 +784,9 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
try:
proc = subprocess.Popen ([driver_bin, "cat", url],
shell=False,
stdin=io.FileIO("/dev/null"),
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=io.FileIO("/dev/null", "w"))
stderr=subprocess.DEVNULL)
return (new_ppd_filename, proc.stdout)
except OSError:
pass
@ -814,9 +813,9 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
try:
proc = subprocess.Popen (['gunzip', '-c', new_ppd_filename],
shell=False,
stdin=io.FileIO("/dev/null"),
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=io.FileIO("/dev/null", "w"))
stderr=subprocess.DEVNULL)
except OSError as err:
(e, s) = err.args
print ("can't open for decompression: %s" % s)
@ -903,10 +902,9 @@ def find_ppd (gutenprintfilename, drivername, lang, region):
try:
p = subprocess.Popen (cmdline,
stdin=io.FileIO("/dev/null"),
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=io.FileIO("/dev/null",
"w"))
stderr=subprocess.DEVNULL)
except OSError:
new_file_version = ""
else:

View File

@ -40,7 +40,7 @@ dry_run = True
def generate_ppd (ppdfile, printer, driver):
p = subprocess.Popen (["foomatic-ppdfile", "-p", printer, "-d", driver],
stdin=io.FileIO ("/dev/null"),
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(ppd, stderr) = p.communicate ()