MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / getConsoleWidth

Function getConsoleWidth

lib/core/common.py:2346–2378  ·  view source on GitHub ↗

Returns console width >>> any((getConsoleWidth(), True)) True

(default=80)

Source from the content-addressed store, hash-verified

2344
2345@cachedmethod
2346def getConsoleWidth(default=80):
2347 """
2348 Returns console width
2349
2350 >>> any((getConsoleWidth(), True))
2351 True
2352 """
2353
2354 width = None
2355
2356 if os.getenv("COLUMNS", "").isdigit():
2357 width = int(os.getenv("COLUMNS"))
2358 else:
2359 try:
2360 output = shellExec("stty size")
2361 match = re.search(r"\A\d+ (\d+)", output)
2362
2363 if match:
2364 width = int(match.group(1))
2365 except (OSError, MemoryError):
2366 pass
2367
2368 if width is None:
2369 try:
2370 import curses
2371
2372 stdscr = curses.initscr()
2373 _, width = stdscr.getmaxyx()
2374 curses.endwin()
2375 except:
2376 pass
2377
2378 return width or default
2379
2380def shellExec(cmd):
2381 """

Callers 4

_cleanupOptionsFunction · 0.90
unionUseFunction · 0.90
_errorFieldsFunction · 0.90
clearConsoleLineFunction · 0.85

Calls 2

shellExecFunction · 0.70
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…