From ea8cc8e666d7b2644734391a25f1eb6549fdb179 Mon Sep 17 00:00:00 2001 From: Etoh Date: Sun, 17 Sep 2023 15:10:50 +0100 Subject: [PATCH] Add Utils support for Windows console --- syncplay/utils.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/syncplay/utils.py b/syncplay/utils.py index 71572f1..29f6a11 100755 --- a/syncplay/utils.py +++ b/syncplay/utils.py @@ -37,6 +37,8 @@ def isMacOS(): def isBSD(): return constants.OS_BSD in sys.platform or sys.platform.startswith(constants.OS_DRAGONFLY) +def isWindowsConsole(): + return os.path.basename(sys.executable) == "SyncplayConsole.exe" def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None): """Retry calling the decorated function using an exponential backoff. @@ -225,6 +227,28 @@ def blackholeStdoutForFrozenWindow(): sys.stdout = Blackhole() del Blackhole + elif getattr(sys, 'frozen', '') == "console_exe": + class Blackhole(object): + softspace = 0 + + def write(self, text): + pass + + def flush(self): + pass + + class Stderr(object): + softspace = 0 + _file = None + _error = None + + def flush(self): + if self._file is not None: + self._file.flush() + + sys.stderr = Blackhole() + del Blackhole + def truncateText(unicodeText, maxLength): try: