diff options
author | Chris Lumens <clumens@redhat.com> | 2006-07-21 14:28:33 +0000 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2006-07-21 14:28:33 +0000 |
commit | b9f8b54295e8dbdf138a6166d5e007543d5dec3b (patch) | |
tree | 72c82906231e374f9fafe5bc7fdb73ad86cfb05a /iutil.py | |
parent | 13e234b45081e3ac0060fb6587c36dac2dd0c8ab (diff) | |
download | anaconda-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.py | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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") |