[node-patches] Change in ovirt-node[master]: utils: Make terminal detection more safe

fabiand at redhat.com fabiand at redhat.com
Tue Jun 30 12:24:00 UTC 2015


Fabian Deutsch has uploaded a new change for review.

Change subject: utils: Make terminal detection more safe
......................................................................

utils: Make terminal detection more safe

Change-Id: I8d705fd63122a2884b232176bbe64d80ef0d0060
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/utils/console.py
1 file changed, 9 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/45/43045/1

diff --git a/src/ovirt/node/utils/console.py b/src/ovirt/node/utils/console.py
index 898a27a..672571b 100644
--- a/src/ovirt/node/utils/console.py
+++ b/src/ovirt/node/utils/console.py
@@ -47,9 +47,15 @@
     >>> is_terminal("/dev/console")
     True
     """
-    ttyname = path or os.ttyname(sys.stdin.fileno())
-    return (re.match("/dev/tty([0-9]|$)", ttyname) is not None
-            or ttyname == "/dev/console")
+    is_terminal = False
+    try:
+        ttyname = path or os.ttyname(sys.stdin.fileno())
+        is_tty = re.match("/dev/tty([0-9]|$)", ttyname) is not None
+        is_console = ttyname == "/dev/console"
+        is_terminal = is_tty or is_console
+    except OSError:
+        pass
+    return is_terminal
 
 
 def is_pty():


-- 
To view, visit https://gerrit.ovirt.org/43045
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8d705fd63122a2884b232176bbe64d80ef0d0060
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at redhat.com>
Gerrit-Reviewer: Fabian Deutsch <fabiand at redhat.com>



More information about the node-patches mailing list