Explorar o código

Fix bug so one can catch the output

oz123 %!s(int64=10) %!d(string=hai) anos
pai
achega
0e212ed3c8
Modificáronse 1 ficheiros con 8 adicións e 5 borrados
  1. 8 5
      pwman/ui/tools.py

+ 8 - 5
pwman/ui/tools.py

@@ -182,11 +182,14 @@ def getpassword(question, argsgiven=None,
 
 
 def gettermsize():  # pragma: no cover
-    s = struct.pack("HHHH", 0, 0, 0, 0)
-    f = sys.stdout.fileno()
-    x = fcntl.ioctl(f, termios.TIOCGWINSZ, s)
-    rows, cols, width, height = struct.unpack("HHHH", x)
-    return rows, cols
+    if sys.stdout.isatty():
+        s = struct.pack("HHHH", 0, 0, 0, 0)
+        f = sys.stdout.fileno()
+        x = fcntl.ioctl(f, termios.TIOCGWINSZ, s)
+        rows, cols, width, height = struct.unpack("HHHH", x)
+        return rows, cols
+    else:
+        return 40, 80
 
 
 def getinput(question, default="", reader=raw_input,