do not use ansi escape codes and readline if on windows
This commit is contained in:
parent
109303f136
commit
a82cfded8c
@ -4,7 +4,10 @@ import sys
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import readline
|
try:
|
||||||
|
import readline
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
import syncplay
|
import syncplay
|
||||||
from syncplay import constants
|
from syncplay import constants
|
||||||
@ -15,6 +18,7 @@ from syncplay.utils import formatTime, isURL
|
|||||||
|
|
||||||
class ConsoleUI(threading.Thread):
|
class ConsoleUI(threading.Thread):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.isWindows = sys.platform.startswith(constants.OS_WINDOWS)
|
||||||
self.promptMode = threading.Event()
|
self.promptMode = threading.Event()
|
||||||
self.PromptResult = ""
|
self.PromptResult = ""
|
||||||
self.promptMode.set()
|
self.promptMode.set()
|
||||||
@ -106,11 +110,13 @@ class ConsoleUI(threading.Thread):
|
|||||||
message = message.decode('utf-8')
|
message = message.decode('utf-8')
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
pass
|
pass
|
||||||
|
if not self.isWindows:
|
||||||
sys.stdout.write('\33[2K\r')
|
sys.stdout.write('\33[2K\r')
|
||||||
if noTimestamp:
|
if noTimestamp:
|
||||||
print(message)
|
print(message)
|
||||||
else:
|
else:
|
||||||
print(time.strftime(constants.UI_TIME_FORMAT, time.localtime()) + message)
|
print(time.strftime(constants.UI_TIME_FORMAT, time.localtime()) + message)
|
||||||
|
if not self.isWindows:
|
||||||
line = readline.get_line_buffer()
|
line = readline.get_line_buffer()
|
||||||
if line != '':
|
if line != '':
|
||||||
print(line, end='')
|
print(line, end='')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user