Skip to content

Commit

Permalink
Add Utils support for Windows console
Browse files Browse the repository at this point in the history
  • Loading branch information
Et0h authored Sep 17, 2023
1 parent f15a87f commit ea8cc8e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions syncplay/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -225,6 +227,28 @@ def flush(self):
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:
Expand Down

0 comments on commit ea8cc8e

Please sign in to comment.