[gutenprint] Use subprocess.DEVNULL in python scripts.
Tim Waugh
twaugh at fedoraproject.org
Fri Aug 22 11:29:02 UTC 2014
commit 71c633e3d9f56c8312ed8b0464b9e46bb5297ce1
Author: Tim Waugh <twaugh at redhat.com>
Date: Fri Aug 22 12:27:30 2014 +0100
Use subprocess.DEVNULL in python scripts.
cups-genppdupdate.py.in | 24 +++++++++++-------------
gutenprint-foomaticppdupdate | 2 +-
2 files changed, 12 insertions(+), 14 deletions(-)
---
diff --git a/cups-genppdupdate.py.in b/cups-genppdupdate.py.in
index d5f8b8f..1a4c5ce 100755
--- a/cups-genppdupdate.py.in
+++ b/cups-genppdupdate.py.in
@@ -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:
diff --git a/gutenprint-foomaticppdupdate b/gutenprint-foomaticppdupdate
index d5bb0c8..5e35ee0 100644
--- a/gutenprint-foomaticppdupdate
+++ b/gutenprint-foomaticppdupdate
@@ -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 ()
More information about the scm-commits
mailing list