|
133 | 133 | from lib.core.settings import INFERENCE_UNKNOWN_CHAR |
134 | 134 | from lib.core.settings import IP_ADDRESS_REGEX |
135 | 135 | from lib.core.settings import ISSUES_PAGE |
| 136 | +from lib.core.settings import IS_TTY |
136 | 137 | from lib.core.settings import IS_WIN |
137 | 138 | from lib.core.settings import LARGE_OUTPUT_THRESHOLD |
138 | 139 | from lib.core.settings import LOCALHOST |
@@ -928,7 +929,7 @@ def setColor(message, color=None, bold=False, level=None, istty=None): |
928 | 929 | retVal = message |
929 | 930 | level = level or extractRegexResult(r"\[(?P<result>%s)\]" % '|'.join(_[0] for _ in getPublicTypeMembers(LOGGING_LEVELS)), message) |
930 | 931 |
|
931 | | - if message and getattr(LOGGER_HANDLER, "is_tty", False) or istty: # colorizing handler |
| 932 | + if message and IS_TTY or istty: # colorizing handler |
932 | 933 | if bold or color: |
933 | 934 | retVal = colored(message, color=color, on_color=None, attrs=("bold",) if bold else None) |
934 | 935 | elif level: |
@@ -1064,7 +1065,7 @@ def readInput(message, default=None, checkBatch=True, boolean=False): |
1064 | 1065 | elif answer is None and retVal: |
1065 | 1066 | retVal = "%s,%s" % (retVal, getUnicode(item, UNICODE_ENCODING)) |
1066 | 1067 |
|
1067 | | - if message and getattr(LOGGER_HANDLER, "is_tty", False): |
| 1068 | + if message and IS_TTY: |
1068 | 1069 | message = "\r%s" % message |
1069 | 1070 |
|
1070 | 1071 | if retVal: |
@@ -1256,7 +1257,7 @@ def banner(): |
1256 | 1257 | if not any(_ in sys.argv for _ in ("--version", "--api")) and not conf.get("disableBanner"): |
1257 | 1258 | _ = BANNER |
1258 | 1259 |
|
1259 | | - if not getattr(LOGGER_HANDLER, "is_tty", False) or "--disable-coloring" in sys.argv: |
| 1260 | + if not IS_TTY or "--disable-coloring" in sys.argv: |
1260 | 1261 | _ = clearColors(_) |
1261 | 1262 | elif IS_WIN: |
1262 | 1263 | coloramainit() |
@@ -2168,7 +2169,7 @@ def clearConsoleLine(forceOutput=False): |
2168 | 2169 | Clears current console line |
2169 | 2170 | """ |
2170 | 2171 |
|
2171 | | - if getattr(LOGGER_HANDLER, "is_tty", False): |
| 2172 | + if IS_TTY: |
2172 | 2173 | dataToStdout("\r%s\r" % (" " * (getConsoleWidth() - 1)), forceOutput) |
2173 | 2174 |
|
2174 | 2175 | kb.prependFlag = False |
|
0 commit comments