Python ntpq

Achim Gratz Stromeko at
Sun Nov 27 14:02:56 UTC 2016

Achim Gratz writes:
> Although I still think the limiting should be done in ntpq (or any other
> program using utils) rather than there so that one can override the
> termwidth from the top-level caller without second-guessing by util.

The more general way to do that would be to have util.termsize take
optional arguments that specify the maximum termsize to return.

--- a/pylib/
+++ b/pylib/
@@ -61,7 +61,7 @@ def canonicalize_dns(hostname, family=socket.AF_UNSPEC):
         return canonicalized.lower() + portsuffix
     return name[0].lower() + portsuffix
-def termsize():
+def termsize(maxrows=0, maxcols=0):
     "Return the current terminal size."
     # Should work under Linux and Solaris at least.
     # Alternatives at
@@ -72,8 +72,10 @@ def termsize():
         return (24, 80)
     for pattern in ('rows\D+(\d+); columns\D+(\d+);', '\s+(\d+)\D+rows;\s+(\d+)\D+columns;'):
         m =, output)
+        rows = int(
+        cols = int(
         if m:
-            return int(, int(
+            return ((min(rows,maxrows) or rows), (min(cols,maxcols) or cols))
     return (24, 80)

+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Q+, Q and microQ:

More information about the devel mailing list