--- pyanaconda/iutil.py | 39 +++++++++++++++++++++++++++------------ pyanaconda/platform.py | 2 +- pyanaconda/storage/udev.py | 2 +- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py index d29bf1e..a8bccb8 100644 --- a/pyanaconda/iutil.py +++ b/pyanaconda/iutil.py @@ -102,16 +102,22 @@ def execWithRedirect(command, argv, stdin = None, stdout = None, stdin = sys.stdin.fileno() if isinstance(stdout, str): - stdout = os.open(stdout, os.O_RDWR|os.O_CREAT) - stdoutclose = lambda : os.close(stdout) + try: + stdout = os.open(stdout, os.O_RDWR|os.O_CREAT) + stdoutclose = lambda : os.close(stdout) + except OSError: + stdout = sys.stdout.fileno() elif isinstance(stdout, int): pass elif stdout is None or not isinstance(stdout, file): stdout = sys.stdout.fileno() if isinstance(stderr, str): - stderr = os.open(stderr, os.O_RDWR|os.O_CREAT) - stderrclose = lambda : os.close(stderr) + try: + stderr = os.open(stderr, os.O_RDWR|os.O_CREAT) + stderrclose = lambda : os.close(stderr) + except OSError: + stderr = sys.stderr.fileno() elif isinstance(stderr, int): pass elif stderr is None or not isinstance(stderr, file): @@ -171,7 +177,7 @@ def execWithRedirect(command, argv, stdin = None, stdout = None, stdinclose() stdoutclose() stderrclose() - raise RuntimeError, errstr + raise RuntimeError(errstr) return ret @@ -206,8 +212,11 @@ def execWithCapture(command, argv, stdin = None, stderr = None, root='/'): stdin = sys.stdin.fileno() if isinstance(stderr, str): - stderr = os.open(stderr, os.O_RDWR|os.O_CREAT) - stderrclose = lambda : os.close(stderr) + try: + stderr = os.open(stderr, os.O_RDWR|os.O_CREAT) + stderrclose = lambda : os.close(stderr) + except OSError: + stderr = sys.stderr.fileno() elif isinstance(stderr, int): pass elif stderr is None or not isinstance(stderr, file): @@ -239,7 +248,7 @@ def execWithCapture(command, argv, stdin = None, stderr = None, root='/'): except OSError as e: log.error ("Error running " + command + ": " + e.strerror) closefds() - raise RuntimeError, "Error running " + command + ": " + e.strerror + raise RuntimeError("Error running " + command + ": " + e.strerror) closefds() return rc @@ -270,16 +279,22 @@ def execWithCallback(command, argv, stdin = None, stdout = None, stdin = sys.stdin.fileno() if isinstance(stdout, str): - stdout = os.open(stdout, os.O_RDWR|os.O_CREAT) - stdoutclose = lambda : os.close(stdout) + try: + stdout = os.open(stdout, os.O_RDWR|os.O_CREAT) + stdoutclose = lambda : os.close(stdout) + except OSError: + stdout = sys.stdout.fileno() elif isinstance(stdout, int): pass elif stdout is None or not isinstance(stdout, file): stdout = sys.stdout.fileno() if isinstance(stderr, str): - stderr = os.open(stderr, os.O_RDWR|os.O_CREAT) - stderrclose = lambda : os.close(stderr) + try: + stderr = os.open(stderr, os.O_RDWR|os.O_CREAT) + stderrclose = lambda : os.close(stderr) + except OSError: + stderr = sys.stderr.fileno() elif isinstance(stderr, int): pass elif stderr is None or not isinstance(stderr, file): diff --git a/pyanaconda/platform.py b/pyanaconda/platform.py index 0535d59..ba0a731 100644 --- a/pyanaconda/platform.py +++ b/pyanaconda/platform.py @@ -182,7 +182,7 @@ class X86(Platform): buf = iutil.execWithCapture("dmidecode", ["-s", "chassis-manufacturer"], stderr="/dev/tty5") - except OSError: + except (OSError, RuntimeError): log.info("Skipping dmidecode call due to running as non-root.") return diff --git a/pyanaconda/storage/udev.py b/pyanaconda/storage/udev.py index 87d3cf8..53b6faf 100644 --- a/pyanaconda/storage/udev.py +++ b/pyanaconda/storage/udev.py @@ -88,7 +88,7 @@ def udev_get_block_devices(): stdout = "/dev/tty5", stderr="/dev/tty5") iutil.execWithRedirect("rmmod", [ "scsi_wait_scan" ], stdout = "/dev/tty5", stderr="/dev/tty5") - except OSError: + except (OSError, RuntimeError): log.info("Skipping scsi_wait_scan due to running as non-root.") udev_settle() -- 1.7.8 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list