mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-26 01:40:12 -05:00
generate-alt-random: ioctl(TIOCGWINSZ) may fail in run inside a container
This _should_ only happen when we’re doing a partial PGO build, since then the script is run in the parent terminal. In this case, the user is expected to use --rows/--cols anyway.
This commit is contained in:
parent
aa13dfb4e8
commit
e4ae5a7586
2 changed files with 18 additions and 5 deletions
|
|
@ -33,6 +33,10 @@
|
||||||
### Deprecated
|
### Deprecated
|
||||||
### Removed
|
### Removed
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
* `generate-alt-random.py` failing in containers.
|
||||||
|
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
### Contributors
|
### Contributors
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,17 @@ def main():
|
||||||
opts = parser.parse_args()
|
opts = parser.parse_args()
|
||||||
out = opts.out if opts.out is not None else sys.stdout
|
out = opts.out if opts.out is not None else sys.stdout
|
||||||
|
|
||||||
lines, cols, height, width = struct.unpack(
|
try:
|
||||||
'HHHH',
|
lines, cols, height, width = struct.unpack(
|
||||||
fcntl.ioctl(sys.stdout.fileno(),
|
'HHHH',
|
||||||
termios.TIOCGWINSZ,
|
fcntl.ioctl(sys.stdout.fileno(),
|
||||||
struct.pack('HHHH', 0, 0, 0, 0)))
|
termios.TIOCGWINSZ,
|
||||||
|
struct.pack('HHHH', 0, 0, 0, 0)))
|
||||||
|
except OSError:
|
||||||
|
lines = None
|
||||||
|
cols = None
|
||||||
|
height = None
|
||||||
|
width = None
|
||||||
|
|
||||||
if opts.rows is not None:
|
if opts.rows is not None:
|
||||||
lines = opts.rows
|
lines = opts.rows
|
||||||
|
|
@ -50,6 +56,9 @@ def main():
|
||||||
cols = opts.cols
|
cols = opts.cols
|
||||||
width = 8 * cols # PGO help binary hardcodes cell width to 8px
|
width = 8 * cols # PGO help binary hardcodes cell width to 8px
|
||||||
|
|
||||||
|
if lines is None or cols is None or height is None or width is None:
|
||||||
|
raise Exception('could not get terminal width/height; use --rows and --cols')
|
||||||
|
|
||||||
# Number of characters to write to screen
|
# Number of characters to write to screen
|
||||||
count = 256 * 1024**1
|
count = 256 * 1024**1
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue