summaryrefslogtreecommitdiffstats
path: root/iutil.py
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2006-07-21 14:28:33 +0000
committerChris Lumens <clumens@redhat.com>2006-07-21 14:28:33 +0000
commitb9f8b54295e8dbdf138a6166d5e007543d5dec3b (patch)
tree72c82906231e374f9fafe5bc7fdb73ad86cfb05a /iutil.py
parent13e234b45081e3ac0060fb6587c36dac2dd0c8ab (diff)
downloadanaconda-b9f8b54295e8dbdf138a6166d5e007543d5dec3b.tar.gz
anaconda-b9f8b54295e8dbdf138a6166d5e007543d5dec3b.tar.xz
anaconda-b9f8b54295e8dbdf138a6166d5e007543d5dec3b.zip
Check that any file given for stdin is available before trying to read from it.
Otherwise, use the regular stdin instead.
Diffstat (limited to 'iutil.py')
-rw-r--r--iutil.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/iutil.py b/iutil.py
index c845bc33d..611eccda8 100644
--- a/iutil.py
+++ b/iutil.py
@@ -32,7 +32,10 @@ def execWithRedirect(command, argv, stdin = 0, stdout = 1, stderr = 2,
raise RuntimeError, command + " can not be run"
if type(stdin) == type("string"):
- stdin = open(stdin)
+ if os.access(stdin, os.R_OK):
+ stdin = open(stdin)
+ else:
+ stdin = 0
if type(stdout) == type("string"):
stdout = open(stdout, "w")
if type(stderr) == type("string"):
@@ -52,7 +55,10 @@ def execWithCapture(command, argv, stdin = 0, stderr = 2, root='/'):
os.chroot(root)
if type(stdin) == type("string"):
- stdin = open(stdin)
+ if os.access(stdin, os.R_OK):
+ stdin = open(stdin)
+ else:
+ stdin = 0
if type(stderr) == type("string"):
stderr = open(stderr, "w")