Full UTF8 support added (#66);
Server probably won't run on python 2.6 anymore
This commit is contained in:
parent
43a79fcbc6
commit
f4af2127a8
@ -5,6 +5,7 @@ import sys
|
||||
from syncplay import constants, utils
|
||||
from syncplay.messages import getMessage
|
||||
from syncplay.players.playerFactory import PlayerFactory
|
||||
import codecs
|
||||
try:
|
||||
from syncplay.ui.GuiConfiguration import GuiConfiguration
|
||||
except ImportError:
|
||||
@ -123,7 +124,9 @@ class ConfigurationGetter(object):
|
||||
|
||||
def _parseConfigFile(self, iniPath):
|
||||
parser = SafeConfigParser()
|
||||
parser.read(iniPath)
|
||||
if(not os.path.isfile(iniPath)):
|
||||
open(iniPath, 'w').close()
|
||||
parser.readfp(codecs.open(iniPath, "r", "utf_8_sig"))
|
||||
for section, options in self._iniStructure.items():
|
||||
if(parser.has_section(section)):
|
||||
for option in options:
|
||||
@ -163,7 +166,7 @@ class ConfigurationGetter(object):
|
||||
if(self._config['noStore']):
|
||||
return
|
||||
parser = SafeConfigParser()
|
||||
parser.read(iniPath)
|
||||
parser.readfp(codecs.open(iniPath, "r", "utf_8_sig"))
|
||||
for section, options in self._iniStructure.items():
|
||||
if(not parser.has_section(section)):
|
||||
parser.add_section(section)
|
||||
@ -173,7 +176,7 @@ class ConfigurationGetter(object):
|
||||
changed = True
|
||||
parser.set(section, option, str(self._config[option]))
|
||||
if(changed):
|
||||
parser.write(file(iniPath, "w"))
|
||||
parser.write(codecs.open(iniPath, "wb", "utf_8_sig"))
|
||||
|
||||
def getConfiguration(self):
|
||||
iniPath = self._getConfigurationFilePath()
|
||||
|
||||
@ -2,11 +2,11 @@ from __future__ import print_function
|
||||
import threading
|
||||
import time
|
||||
import syncplay
|
||||
import os
|
||||
import re
|
||||
from syncplay import utils
|
||||
from syncplay import constants
|
||||
from syncplay.messages import getMessage
|
||||
import sys
|
||||
|
||||
class ConsoleUI(threading.Thread):
|
||||
def __init__(self):
|
||||
@ -20,14 +20,17 @@ class ConsoleUI(threading.Thread):
|
||||
self._syncplayClient = client
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
data = raw_input()
|
||||
data = data.rstrip('\n\r')
|
||||
if(not self.promptMode.isSet()):
|
||||
self.PromptResult = data
|
||||
self.promptMode.set()
|
||||
elif(self._syncplayClient):
|
||||
self._executeCommand(data)
|
||||
try:
|
||||
while True:
|
||||
data = raw_input().decode(sys.stdin.encoding)
|
||||
data = data.rstrip('\n\r')
|
||||
if(not self.promptMode.isSet()):
|
||||
self.PromptResult = data
|
||||
self.promptMode.set()
|
||||
elif(self._syncplayClient):
|
||||
self._executeCommand(data)
|
||||
except EOFError:
|
||||
pass
|
||||
|
||||
def promptFor(self, prompt=">", message=""):
|
||||
if message <> "":
|
||||
@ -38,8 +41,7 @@ class ConsoleUI(threading.Thread):
|
||||
return self.PromptResult
|
||||
|
||||
def showMessage(self, message, noTimestamp=False):
|
||||
if(os.name == "nt"):
|
||||
message = message.encode('ascii', 'replace')
|
||||
message = message.encode(sys.stdout.encoding, 'replace')
|
||||
if(noTimestamp):
|
||||
print(message)
|
||||
else:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user