Add Utils support for Windows console

This commit is contained in:
Etoh 2023-09-17 15:10:50 +01:00 committed by GitHub
parent f15a87f92b
commit ea8cc8e666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: