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