|
60 | 60 | except Exception: |
61 | 61 | shared_memory = None |
62 | 62 |
|
| 63 | +def running_interactively(): |
| 64 | + main = sys.modules.get("__main__") |
| 65 | + no_main_file = not hasattr(main, "__file__") |
| 66 | + interactive_flag = bool(getattr(sys.flags, "interactive", 0)) |
| 67 | + return no_main_file or interactive_flag |
| 68 | + |
| 69 | +if running_interactively(): |
| 70 | + logging.basicConfig(format="%(message)s", stream=PY_STDOUT_TEXT, level=logging.DEBUG) |
| 71 | + |
| 72 | +# Windows-specific setup |
| 73 | +if os.name == "nt": |
| 74 | + def _wrap(stream): |
| 75 | + buf = getattr(stream, "buffer", None) |
| 76 | + is_tty = getattr(stream, "isatty", lambda: False)() |
| 77 | + if buf is not None and is_tty: |
| 78 | + try: |
| 79 | + return io.TextIOWrapper(buf, encoding="UTF-8", errors="replace", line_buffering=True) |
| 80 | + except Exception: |
| 81 | + return stream |
| 82 | + return stream |
| 83 | + sys.stdout = _wrap(sys.stdout) |
| 84 | + sys.stderr = _wrap(sys.stderr) |
| 85 | + |
| 86 | +hashlib_guaranteed = False |
| 87 | +# Environment setup |
| 88 | +os.environ["PYTHONIOENCODING"] = "UTF-8" |
| 89 | + |
| 90 | +from io import UnsupportedOperation |
| 91 | + |
63 | 92 | __upload_proto_support__ = "^(http|https|ftp|ftps|sftp|scp|tcp|udp|sctp|data|file|bt|rfcomm|l2cap|bluetooth|unixstream|unixdgram|unixseqpacket)://" |
64 | 93 | __download_proto_support__ = "^(http|https|ftp|ftps|sftp|scp|tcp|udp|sctp|data|file|bt|rfcomm|l2cap|bluetooth|unixstream|unixdgram|unixseqpacket)://" |
65 | 94 | if(platform.python_implementation() != ""): |
|
0 commit comments