mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 04:02:32 +01:00
[output] define and use global TTY_STD... values
This commit is contained in:
parent
e93b8efe7b
commit
ee61256054
@ -11,7 +11,6 @@
|
||||
import os
|
||||
import re
|
||||
import ssl
|
||||
import sys
|
||||
import time
|
||||
import netrc
|
||||
import queue
|
||||
@ -23,7 +22,7 @@ import requests
|
||||
import threading
|
||||
from requests.adapters import HTTPAdapter
|
||||
from .message import Message
|
||||
from .. import config, text, util, cache, exception
|
||||
from .. import config, output, text, util, cache, exception
|
||||
urllib3 = requests.packages.urllib3
|
||||
|
||||
|
||||
@ -289,13 +288,8 @@ class Extractor():
|
||||
|
||||
def _check_input_allowed(self, prompt=""):
|
||||
input = self.config("input")
|
||||
|
||||
if input is None:
|
||||
try:
|
||||
input = sys.stdin.isatty()
|
||||
except Exception:
|
||||
input = False
|
||||
|
||||
input = output.TTY_STDIN
|
||||
if not input:
|
||||
raise exception.StopExtraction(
|
||||
"User input required (%s)", prompt.strip(" :"))
|
||||
|
@ -17,6 +17,22 @@ from . import config, util, formatter
|
||||
# --------------------------------------------------------------------
|
||||
# Globals
|
||||
|
||||
try:
|
||||
TTY_STDOUT = sys.stdout.isatty()
|
||||
except Exception:
|
||||
TTY_STDOUT = False
|
||||
|
||||
try:
|
||||
TTY_STDERR = sys.stderr.isatty()
|
||||
except Exception:
|
||||
TTY_STDERR = False
|
||||
|
||||
try:
|
||||
TTY_STDIN = sys.stdin.isatty()
|
||||
except Exception:
|
||||
TTY_STDIN = False
|
||||
|
||||
|
||||
COLORS = not os.environ.get("NO_COLOR")
|
||||
COLORS_DEFAULT = {
|
||||
"success": "1;32",
|
||||
@ -323,7 +339,7 @@ def select():
|
||||
|
||||
if mode is None or mode == "auto":
|
||||
try:
|
||||
if sys.stdout.isatty():
|
||||
if TTY_STDOUT:
|
||||
output = ColorOutput() if ANSI else TerminalOutput()
|
||||
else:
|
||||
output = PipeOutput()
|
||||
|
Loading…
Reference in New Issue
Block a user