[node-patches] Change in ovirt-node[ovirt-3.5]: Fixing correct terminal detection

fabiand at redhat.com fabiand at redhat.com
Tue Nov 25 17:38:09 UTC 2014


Hello Anatoly Litovsky,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/35565

to review the following change.

Change subject: Fixing correct terminal detection
......................................................................

Fixing correct terminal detection

Avoiding setting fonts of terminal if its not ttyxx terminal
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1162449
Change-Id: I010c2bf79bfe98b3b5ebc2f54246690c1bcfbffc
Signed-off-by: Tolik Litovsky <tlitovsk at redhat.com>
---
M src/ovirt/node/utils/console.py
1 file changed, 20 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/65/35565/1

diff --git a/src/ovirt/node/utils/console.py b/src/ovirt/node/utils/console.py
index 238b6c9..2f2a816 100644
--- a/src/ovirt/node/utils/console.py
+++ b/src/ovirt/node/utils/console.py
@@ -25,14 +25,31 @@
 import os
 import termios
 import tty
+import re
 
 
-def is_terminal():
+def is_terminal(path=None):
     """Is true if the terminal is a real one
     Like the linux terminal console
+
+    >>> is_terminal("/dev/tty0")
+    True
+
+    >>> is_terminal("/dev/ttyUSB0")
+    False
+
+    >>> is_terminal("/dev/ttyS0")
+    False
+
+    >>> is_terminal("/dev/tty")
+    True
+
+    >>> is_terminal("/dev/console")
+    True
     """
-    ttyname = os.ttyname(sys.stdin.fileno())
-    return ttyname.startswith("/dev/tty") or ttyname == "/dev/console"
+    ttyname = path or os.ttyname(sys.stdin.fileno())
+    return (re.match("/dev/tty([0-9]|$)", ttyname) is not None
+            or ttyname == "/dev/console")
 
 
 def is_pty():


-- 
To view, visit http://gerrit.ovirt.org/35565
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I010c2bf79bfe98b3b5ebc2f54246690c1bcfbffc
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Fabian Deutsch <fabiand at redhat.com>
Gerrit-Reviewer: Anatoly Litovsky <tlitovsk at redhat.com>



More information about the node-patches mailing list