Comments (4)
I noticed something similar with termsize.py
and assumed it was something to do with my Konsole → gnu screen /dev/ttyUSB0 115200 8N1
→ Armbian stack, so I did a similar patch.
I also discovered that it appears to be necessary to call get_terminal_size_curses
before get_terminal_size_noncurses
to avoid some kind of race condition which
results in rows, cols = list(map(int, re.findall(r'\d+', output)))
intermittently dying with an error about expecting to unpack 2 things
but getting 0.
from scripts.
Sorry, I haven't been able to reproduce this, so I'm not sure what's going on. It still works for me on Debian sid in urxvt, xterm and the console, and when sshed to a Raspbian raspberry pi from urxvt and the console.
get_terminal_size_curses() is always called first, and get_terminal_size_noncurses will only be called if the curses version fails.
It might help to see the actual error message.
People seeing failures: what is TERM set to? I've tried it with TERM=rxvt-unicode-256color, TERM=xterm and TERM=linux.
from scripts.
Here is my setup:
- Konsole 19.12.3 from Kubuntu Linux 20.04 LTS
- GNU Screen 4.08.00 (GNU) 05-Feb-20 from Kubuntu Linux 20.04 LTS
- The Debian image for the Cubox i4Pro linked at https://solidrun.atlassian.net/wiki/spaces/developer/pages/197493654#Booting-form-an-SD-card
- Connecting from the Kubuntu box to the Debian box over a serial console via
screen /dev/ttyUSB0 115200 8N1
, since I've never had the terminal dimensions not be set correctly when using SSH, so I had no reason to need any help with it.
With your stock script, I had to patch the shebang line because I only have python3
installed and didn't want to potentially complicate diagnosing future problems porting old scripts by setting python
to point to python3
rather than python2
. (I believe the official way to do that is to install the python-is-python3
package.)
Once that was done, with the default TERM=vt220
, it "runs fine"... but the result is Reset the terminal to 24 rows, 80 cols
when the terminal's actual size is 243 columns by 50 rows.
Using export TERM=xterm
, export TERM=xterm-color
or export TERM=screen
has no observable effect aside from preventing the screen-clearing behaviour which occurs as a side-effect with TERM=vt220
.
Commenting out the rows, cols = get_terminal_size_curses()
and the associated try
/except
and unindenting rows, cols = get_terminal_size_noncurses()
causes it to randomly choose between one of the following two outputs, with the aforementioned changes to TERM
seeming to have no effect:
debian@sr-imx6:~$ ./termsize
Reset the terminal to 50 rows, 243 cols
debian@sr-imx6:~$ ./termsize
0;243RTraceback (most recent call last):
File "/home/debian/./termsize", line 91, in <module>
rows, cols = get_terminal_size_noncurses()
File "/home/debian/./termsize", line 82, in get_terminal_size_noncurses
rows, cols = list(map(int, re.findall(r'\d+', output)))
ValueError: not enough values to unpack (expected 2, got 0)
Note the scrollbar on that code block. In both cases, the first line of output has a ton of whitespace before it. In fact, it appears to consistently be one less than the length needed to make it wrap, so it appears to be eset the terminal to 50 rows, 243 cols
and ;243RTraceback (most recent call last):
on a terminal that's doing line-wrapping.
Adding a print(repr(output))
reveals the contents of output
that are causing the ValueError
to be \x1b[
as opposed to \x1b[50;243R
in the successful case.
from scripts.
for me I have tried WezTerm and stock Terminal on on OSX, as well as gnome-terminal on Ubuntu and they all do the same thing, getmaxyx() always returns whatever the terminal is set to (i.e. the output of stty -a), which is by default 24,80.
I think thats why it works after using the noncurses version as noncurses sets it to correct values.
TERM is set to vt220, but tried linux, rxvt-unicode-256color, screen, no difference
on the host system python is 3.9.2, debian 11 if it makes a difference
from scripts.
Related Issues (14)
- termsize: without python HOT 4
- Awesome HOT 3
- be resilient to decoding issues? HOT 2
- conjunctions.py crash HOT 1
- Suggested add, to remove blank line before 'Reset...' text... HOT 4
- termsize: extra characters in urxvt HOT 1
- viewhtmlmail chokes on maildir HOT 3
- viewhtmlmail.py fails for certain characters HOT 1
- viewhtmlmail.py with Firefox HOT 9
- weborphans - will it work for website created by MkDocs? HOT 14
- termsize won't work with Python3 HOT 4
- python 3 and block=false HOT 1
- Can't install python-poppler-pyqt5 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scripts.