Use subprocess.DEVNULL in python scripts.
This commit is contained in:
parent
ce129d3443
commit
71c633e3d9
@ -103,9 +103,9 @@ def get_driver_version():
|
|||||||
def run_with_arg (arg):
|
def run_with_arg (arg):
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen ([driver_bin, arg],
|
p = subprocess.Popen ([driver_bin, arg],
|
||||||
stdin=io.FileIO("/dev/null"),
|
stdin=subprocess.DEVNULL,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=io.FileIO("/dev/null", "w"),
|
stderr=subprocess.DEVNULL,
|
||||||
shell=False)
|
shell=False)
|
||||||
(stdout, stderr) = p.communicate ()
|
(stdout, stderr) = p.communicate ()
|
||||||
except OSError:
|
except OSError:
|
||||||
@ -612,8 +612,8 @@ def update_ppd (ppd_source_filename):
|
|||||||
|
|
||||||
chcon = subprocess.Popen (["chcon", "--reference=%s" % ppd_dest_filename,
|
chcon = subprocess.Popen (["chcon", "--reference=%s" % ppd_dest_filename,
|
||||||
tmpnew], shell=False,
|
tmpnew], shell=False,
|
||||||
stdin=io.FileIO("/dev/null"),
|
stdin=subprocess.DEVNULL,
|
||||||
stdout=io.FileIO("/dev/null", "w"),
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
chcon.communicate ()
|
chcon.communicate ()
|
||||||
|
|
||||||
@ -771,8 +771,7 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
|
|||||||
shell=False,
|
shell=False,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=io.FileIO("/dev/null",
|
stderr=subprocess.DEVNULL)
|
||||||
"w"))
|
|
||||||
server_multicat_initialized = mc_proc
|
server_multicat_initialized = mc_proc
|
||||||
|
|
||||||
print ("%s" % url, file=server_multicat_initialized.stdin)
|
print ("%s" % url, file=server_multicat_initialized.stdin)
|
||||||
@ -785,9 +784,9 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
|
|||||||
try:
|
try:
|
||||||
proc = subprocess.Popen ([driver_bin, "cat", url],
|
proc = subprocess.Popen ([driver_bin, "cat", url],
|
||||||
shell=False,
|
shell=False,
|
||||||
stdin=io.FileIO("/dev/null"),
|
stdin=subprocess.DEVNULL,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=io.FileIO("/dev/null", "w"))
|
stderr=subprocess.DEVNULL)
|
||||||
return (new_ppd_filename, proc.stdout)
|
return (new_ppd_filename, proc.stdout)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
@ -814,9 +813,9 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
|
|||||||
try:
|
try:
|
||||||
proc = subprocess.Popen (['gunzip', '-c', new_ppd_filename],
|
proc = subprocess.Popen (['gunzip', '-c', new_ppd_filename],
|
||||||
shell=False,
|
shell=False,
|
||||||
stdin=io.FileIO("/dev/null"),
|
stdin=subprocess.DEVNULL,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=io.FileIO("/dev/null", "w"))
|
stderr=subprocess.DEVNULL)
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
(e, s) = err.args
|
(e, s) = err.args
|
||||||
print ("can't open for decompression: %s" % s)
|
print ("can't open for decompression: %s" % s)
|
||||||
@ -903,10 +902,9 @@ def find_ppd (gutenprintfilename, drivername, lang, region):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen (cmdline,
|
p = subprocess.Popen (cmdline,
|
||||||
stdin=io.FileIO("/dev/null"),
|
stdin=subprocess.DEVNULL,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=io.FileIO("/dev/null",
|
stderr=subprocess.DEVNULL)
|
||||||
"w"))
|
|
||||||
except OSError:
|
except OSError:
|
||||||
new_file_version = ""
|
new_file_version = ""
|
||||||
else:
|
else:
|
||||||
|
@ -40,7 +40,7 @@ dry_run = True
|
|||||||
|
|
||||||
def generate_ppd (ppdfile, printer, driver):
|
def generate_ppd (ppdfile, printer, driver):
|
||||||
p = subprocess.Popen (["foomatic-ppdfile", "-p", printer, "-d", driver],
|
p = subprocess.Popen (["foomatic-ppdfile", "-p", printer, "-d", driver],
|
||||||
stdin=io.FileIO ("/dev/null"),
|
stdin=subprocess.DEVNULL,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
(ppd, stderr) = p.communicate ()
|
(ppd, stderr) = p.communicate ()
|
||||||
|
Loading…
Reference in New Issue
Block a user