Merge 35f3c3e6b3a827df86c8ce611265a4985b99b992 into d4bd954ad1d0371b21685217f1f10a52c92dffb1
This commit is contained in:
commit
34c5de941e
@ -1,6 +1,7 @@
|
|||||||
from syncplay.client import SyncplayClient
|
from syncplay.client import SyncplayClient
|
||||||
from syncplay.ui.ConfigurationGetter import ConfigurationGetter
|
from syncplay.ui.ConfigurationGetter import ConfigurationGetter
|
||||||
from syncplay import ui
|
from syncplay import ui
|
||||||
|
from syncplay.messages import getMessage
|
||||||
try:
|
try:
|
||||||
from syncplay.players.mpc import MPCHCAPIPlayer
|
from syncplay.players.mpc import MPCHCAPIPlayer
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -20,7 +21,7 @@ class SyncplayClientManager(object):
|
|||||||
interface.addClient(syncplayClient)
|
interface.addClient(syncplayClient)
|
||||||
syncplayClient.start(config['host'], config['port'])
|
syncplayClient.start(config['host'], config['port'])
|
||||||
else:
|
else:
|
||||||
interface.showErrorMessage("Unable to start client")
|
interface.showErrorMessage(getMessage("en", "unable-to-start-client-error"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,8 @@ en = {
|
|||||||
"reconnection-attempt-notification" : "Connection with server lost, attempting to reconnect",
|
"reconnection-attempt-notification" : "Connection with server lost, attempting to reconnect",
|
||||||
"disconnection-notification" : "Disconnected from server",
|
"disconnection-notification" : "Disconnected from server",
|
||||||
"connection-failed-notification" : "Connection with server failed",
|
"connection-failed-notification" : "Connection with server failed",
|
||||||
|
"connected-successful-notification" : "Successfully connected to server",
|
||||||
|
"retrying-notification" : "%s, Retrying in %d seconds...", #Seconds
|
||||||
|
|
||||||
"rewind-notification" : "Rewinded due to time difference with <{}>", #User
|
"rewind-notification" : "Rewinded due to time difference with <{}>", #User
|
||||||
"slowdown-notification" : "Slowing down due to time difference with <{}>", #User
|
"slowdown-notification" : "Slowing down due to time difference with <{}>", #User
|
||||||
@ -31,11 +33,85 @@ en = {
|
|||||||
"notplaying-notification" : "People who are not playing any file:",
|
"notplaying-notification" : "People who are not playing any file:",
|
||||||
"userlist-room-notification" : "In room '{}':", #Room
|
"userlist-room-notification" : "In room '{}':", #Room
|
||||||
|
|
||||||
|
"mplayer-file-required-notification" : "Syncplay using mplayer requires you to provide file when starting",
|
||||||
|
"mplayer-file-required-notification/example" : "Usage example: syncplay [options] [url|path/]filename",
|
||||||
|
|
||||||
|
"unrecognized-command-notification" : "Unrecognized command",
|
||||||
|
"commandlist-notification" : "Available commands:",
|
||||||
|
"commandlist-notification/room" : "\tr [name] - change room",
|
||||||
|
"commandlist-notification/list" : "\tl - show user list",
|
||||||
|
"commandlist-notification/undo" : "\tu - undo last seek",
|
||||||
|
"commandlist-notification/pause" : "\tp - toggle pause",
|
||||||
|
"commandlist-notification/seek" : "\t[s][+-]time - seek to the given value of time, if + or - is not specified it's absolute time in seconds or min:sec",
|
||||||
|
"commandlist-notification/help" : "\th - this help",
|
||||||
|
"syncplay-version-notification" : "Syncplay version: {}", #syncplay.version
|
||||||
|
"more-info-notification" : "More info available at: {}", #projectURL
|
||||||
|
|
||||||
# Client prompts
|
# Client prompts
|
||||||
"enter-to-exit-prompt" : "Press enter to exit\n",
|
"enter-to-exit-prompt" : "Press enter to exit\n",
|
||||||
|
|
||||||
# Client errors
|
# Client errors
|
||||||
"server-timeout-error" : "Connection with server timed out"
|
"server-timeout-error" : "Connection with server timed out",
|
||||||
|
"mpc-slave-error" : "Unable to start MPC in slave mode!",
|
||||||
|
"mpc-version-insufficient-error" : "MPC version not sufficient, please use `mpc-hc` >= `1.6.4`",
|
||||||
|
"player-file-open-error" : "Player failed opening file",
|
||||||
|
"player-path-error" : "Player path is not set properly",
|
||||||
|
"hostname-empty-error" : "Hostname can't be empty",
|
||||||
|
"empty-error" : "{} can't be empty", #Configuration
|
||||||
|
|
||||||
|
"arguments-missing-error" : "Some necessary arguments are missing, refer to --help",
|
||||||
|
|
||||||
|
"unable-to-start-client-error" : "Unable to start client",
|
||||||
|
|
||||||
|
"not-json-error" : "Not a json encoded string\n",
|
||||||
|
"hello-arguments-error" : "Not enough Hello arguments\n",
|
||||||
|
"version-mismatch-error" : "Mismatch between versions of client and server\n",
|
||||||
|
|
||||||
|
# Client arguments
|
||||||
|
"argument-description" : 'Solution to synchronize playback of multiple MPlayer and MPC-HC instances over the network.',
|
||||||
|
"argument-epilog" : 'If no options supplied _config values will be used',
|
||||||
|
"nogui-argument" : 'show no GUI',
|
||||||
|
"host-argument" : 'server\'s address',
|
||||||
|
"name-argument" : 'desired username',
|
||||||
|
"debug-argument" : 'debug mode',
|
||||||
|
"force-gui-prompt-argument" : 'make configuration prompt appear',
|
||||||
|
"no-store-argument" : 'don\'t store values in .syncplay',
|
||||||
|
"room-argument" : 'default room',
|
||||||
|
"password-argument" : 'server password',
|
||||||
|
"player-path-argument" : 'path to your player executable',
|
||||||
|
"file-argument" : 'file to play',
|
||||||
|
"args-argument" : 'player options, if you need to pass options starting with - prepend them with single \'--\' argument',
|
||||||
|
|
||||||
|
# Client labels
|
||||||
|
"host-label" : 'Host: ',
|
||||||
|
"username-label" : 'Username: ',
|
||||||
|
"room-label" : 'Default room (optional): ',
|
||||||
|
"password-label" : 'Server password (optional): ',
|
||||||
|
"path-label" : 'Path to player executable: ',
|
||||||
|
|
||||||
|
# Server notifications
|
||||||
|
"welcome-server-notification" : "Welcome to Syncplay server, ver. {0}", #version
|
||||||
|
"client-connected-room-server-notification" : "{0}({2}) connected to room '{1}'", #username, host, room
|
||||||
|
"client-left-server-notification" : "{0} left server", #name
|
||||||
|
|
||||||
|
|
||||||
|
#Server arguments
|
||||||
|
"server-argument-description" : 'Solution to synchronize playback of multiple MPlayer and MPC-HC instances over the network. Server instance',
|
||||||
|
"server-argument-epilog" : 'If no options supplied _config values will be used',
|
||||||
|
"server-port-argument" : 'server TCP port',
|
||||||
|
"server-password-argument" : 'server password',
|
||||||
|
"server-isolate-room-argument" : 'should rooms be isolated?',
|
||||||
|
|
||||||
|
#Server errors
|
||||||
|
"not-known-server-error" : "You must be known to server before sending this command",
|
||||||
|
"client-drop-server-error" : "Client drop: %s -- %s", #host, error
|
||||||
|
"password-required-server-error" : "Password required",
|
||||||
|
"wrong-password-server-error" : "Wrong password supplied",
|
||||||
|
"hello-server-error" : "Not enough Hello arguments",
|
||||||
|
"version-mismatch-server-error" : "Mismatch between versions of client and server",
|
||||||
|
"wrong-password-server-error" : "Wrong password supplied"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pl = {
|
pl = {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ from syncplay.players.basePlayer import BasePlayer
|
|||||||
import re
|
import re
|
||||||
from syncplay.utils import retry
|
from syncplay.utils import retry
|
||||||
from syncplay import constants
|
from syncplay import constants
|
||||||
|
from syncplay.messages import getMessage
|
||||||
|
|
||||||
class MpcHcApi:
|
class MpcHcApi:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -40,7 +41,7 @@ class MpcHcApi:
|
|||||||
args = "%s /slave %s" % (" ".join(args), str(self.__listener.hwnd))
|
args = "%s /slave %s" % (" ".join(args), str(self.__listener.hwnd))
|
||||||
win32api.ShellExecute(0, "open", path, args, None, 1)
|
win32api.ShellExecute(0, "open", path, args, None, 1)
|
||||||
if(not self.__locks.mpcStart.wait(constants.MPC_OPEN_MAX_WAIT_TIME)):
|
if(not self.__locks.mpcStart.wait(constants.MPC_OPEN_MAX_WAIT_TIME)):
|
||||||
raise self.NoSlaveDetectedException("Unable to start MPC in slave mode!")
|
raise self.NoSlaveDetectedException(getMessage("en", "mpc-slave-error"))
|
||||||
self.__mpcExistenceChecking.start()
|
self.__mpcExistenceChecking.start()
|
||||||
|
|
||||||
def openFile(self, filePath):
|
def openFile(self, filePath):
|
||||||
@ -350,12 +351,12 @@ class MPCHCAPIPlayer(BasePlayer):
|
|||||||
def __dropIfNotSufficientVersion(self):
|
def __dropIfNotSufficientVersion(self):
|
||||||
self._mpcApi.askForVersion()
|
self._mpcApi.askForVersion()
|
||||||
if(not self.__versionUpdate.wait(0.1) or not self._mpcApi.version):
|
if(not self.__versionUpdate.wait(0.1) or not self._mpcApi.version):
|
||||||
self.__mpcError("MPC version not sufficient, please use `mpc-hc` >= `1.6.4`")
|
self.__mpcError(getMessage("en", "mpc-version-insufficient-error"))
|
||||||
self.__client.stop(True)
|
self.__client.stop(True)
|
||||||
|
|
||||||
def __testMpcReady(self):
|
def __testMpcReady(self):
|
||||||
if(not self.__preventAsking.wait(10)):
|
if(not self.__preventAsking.wait(10)):
|
||||||
raise Exception("Player failed opening file")
|
raise Exception(getMessage("en", "player-file-open-error"))
|
||||||
|
|
||||||
def __makePing(self):
|
def __makePing(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import re
|
|||||||
import threading
|
import threading
|
||||||
from syncplay.players.basePlayer import BasePlayer
|
from syncplay.players.basePlayer import BasePlayer
|
||||||
from syncplay import constants
|
from syncplay import constants
|
||||||
|
from syncplay.messages import getMessage
|
||||||
|
|
||||||
class MplayerPlayer(BasePlayer):
|
class MplayerPlayer(BasePlayer):
|
||||||
speedSupported = True
|
speedSupported = True
|
||||||
@ -16,8 +17,8 @@ class MplayerPlayer(BasePlayer):
|
|||||||
try:
|
try:
|
||||||
self._listener = self.__Listener(self, playerPath, filePath, args)
|
self._listener = self.__Listener(self, playerPath, filePath, args)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self._client.ui.showMessage("Syncplay using mplayer requires you to provide file when starting")
|
self._client.ui.showMessage(getMessage("en", "mplayer-file-required-notification"))
|
||||||
self._client.ui.showMessage("Usage example: syncplay [options] [url|path/]filename")
|
self._client.ui.showMessage(getMessage("en", "mplayer-file-required-notification/example"))
|
||||||
self._client.stop(True)
|
self._client.stop(True)
|
||||||
return
|
return
|
||||||
self._listener.setDaemon(True)
|
self._listener.setDaemon(True)
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import json
|
|||||||
import syncplay
|
import syncplay
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
import time
|
import time
|
||||||
|
from syncplay.messages import getMessage
|
||||||
|
|
||||||
class JSONCommandProtocol(LineReceiver):
|
class JSONCommandProtocol(LineReceiver):
|
||||||
def handleMessages(self, messages):
|
def handleMessages(self, messages):
|
||||||
@ -38,7 +39,7 @@ class JSONCommandProtocol(LineReceiver):
|
|||||||
try:
|
try:
|
||||||
messages = json.loads(line)
|
messages = json.loads(line)
|
||||||
except:
|
except:
|
||||||
self.dropWithError("Not a json encoded string\n" + line)
|
self.dropWithError(getMessage("en", "not-json-error") + line)
|
||||||
return
|
return
|
||||||
self.handleMessages(messages)
|
self.handleMessages(messages)
|
||||||
|
|
||||||
@ -81,14 +82,14 @@ class SyncClientProtocol(JSONCommandProtocol):
|
|||||||
def handleHello(self, hello):
|
def handleHello(self, hello):
|
||||||
username, roomName, version = self._extractHelloArguments(hello)
|
username, roomName, version = self._extractHelloArguments(hello)
|
||||||
if(not username or not roomName or not version):
|
if(not username or not roomName or not version):
|
||||||
self.dropWithError("Not enough Hello arguments\n" + hello)
|
self.dropWithError(getMessage("en", "hello-arguments-error") + hello)
|
||||||
elif(version.split(".")[0:2] != syncplay.version.split(".")[0:2]):
|
elif(version.split(".")[0:2] != syncplay.version.split(".")[0:2]):
|
||||||
self.dropWithError("Mismatch between versions of client and server\n" + hello)
|
self.dropWithError(getMessage("en", "version-mismatch-error") + hello)
|
||||||
else:
|
else:
|
||||||
self._client.setUsername(username)
|
self._client.setUsername(username)
|
||||||
self._client.setRoom(roomName)
|
self._client.setRoom(roomName)
|
||||||
self.logged = True
|
self.logged = True
|
||||||
self._client.ui.showMessage("Successfully connected to server")
|
self._client.ui.showMessage(getMessage("en", "connected-successful-notification"))
|
||||||
self._client.sendFile()
|
self._client.sendFile()
|
||||||
|
|
||||||
def sendHello(self):
|
def sendHello(self):
|
||||||
@ -232,12 +233,12 @@ class SyncServerProtocol(JSONCommandProtocol):
|
|||||||
@wraps(f)
|
@wraps(f)
|
||||||
def wrapper(self, *args, **kwds):
|
def wrapper(self, *args, **kwds):
|
||||||
if(not self._logged):
|
if(not self._logged):
|
||||||
self.dropWithError("You must be known to server before sending this command")
|
self.dropWithError(getMessage("en", "not-known-server-error"))
|
||||||
return f(self, *args, **kwds)
|
return f(self, *args, **kwds)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
def dropWithError(self, error):
|
def dropWithError(self, error):
|
||||||
print "Client drop: %s -- %s" % (self.transport.getPeer().host, error)
|
print getMessage("en", "client-drop-server-error") % (self.transport.getPeer().host, error)
|
||||||
self.sendError(error)
|
self.sendError(error)
|
||||||
self.drop()
|
self.drop()
|
||||||
|
|
||||||
@ -260,19 +261,19 @@ class SyncServerProtocol(JSONCommandProtocol):
|
|||||||
def _checkPassword(self, serverPassword):
|
def _checkPassword(self, serverPassword):
|
||||||
if(self._factory.password):
|
if(self._factory.password):
|
||||||
if(not serverPassword):
|
if(not serverPassword):
|
||||||
self.dropWithError("Password required")
|
self.dropWithError(getMessage("en", "password-required-server-error"))
|
||||||
return False
|
return False
|
||||||
if(serverPassword != self._factory.password):
|
if(serverPassword != self._factory.password):
|
||||||
self.dropWithError("Wrong password supplied")
|
self.dropWithError(getMessage("en", "wrong-password-server-error"))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def handleHello(self, hello):
|
def handleHello(self, hello):
|
||||||
username, serverPassword, roomName, roomPassword, version = self._extractHelloArguments(hello)
|
username, serverPassword, roomName, roomPassword, version = self._extractHelloArguments(hello)
|
||||||
if(not username or not roomName or not version):
|
if(not username or not roomName or not version):
|
||||||
self.dropWithError("Not enough Hello arguments")
|
self.dropWithError(getMessage("en", "hello-server-error"))
|
||||||
elif(version.split(".")[0:2] != syncplay.version.split(".")[0:2]):
|
elif(version.split(".")[0:2] != syncplay.version.split(".")[0:2]):
|
||||||
self.dropWithError("Mismatch between versions of client and server")
|
self.dropWithError(getMessage("en", "version-mismatch-server-error"))
|
||||||
else:
|
else:
|
||||||
if(not self._checkPassword(serverPassword)):
|
if(not self._checkPassword(serverPassword)):
|
||||||
return
|
return
|
||||||
|
|||||||
@ -8,10 +8,11 @@ from syncplay.protocols import SyncServerProtocol
|
|||||||
import time
|
import time
|
||||||
from syncplay import constants
|
from syncplay import constants
|
||||||
import threading
|
import threading
|
||||||
|
from syncplay.messages import getMessage
|
||||||
|
|
||||||
class SyncFactory(Factory):
|
class SyncFactory(Factory):
|
||||||
def __init__(self, password = ''):
|
def __init__(self, password = ''):
|
||||||
print "Welcome to Syncplay server, ver. {0}".format(syncplay.version)
|
print getMessage("en", "welcome-server-notification").format(syncplay.version)
|
||||||
if(password):
|
if(password):
|
||||||
password = hashlib.md5(password).hexdigest()
|
password = hashlib.md5(password).hexdigest()
|
||||||
self.password = password
|
self.password = password
|
||||||
@ -44,7 +45,7 @@ class SyncFactory(Factory):
|
|||||||
watcher = Watcher(self, watcherProtocol, username, roomName)
|
watcher = Watcher(self, watcherProtocol, username, roomName)
|
||||||
with self._roomUpdate:
|
with self._roomUpdate:
|
||||||
self._rooms[roomName][watcherProtocol] = watcher
|
self._rooms[roomName][watcherProtocol] = watcher
|
||||||
print "{0}({2}) connected to room '{1}'".format(username, roomName, watcherProtocol.transport.getPeer().host)
|
print getMessage("en", "client-connected-room-server-notification").format(username, roomName, watcherProtocol.transport.getPeer().host)
|
||||||
reactor.callLater(0.1, watcher.scheduleSendState)
|
reactor.callLater(0.1, watcher.scheduleSendState)
|
||||||
l = lambda w: w.sendUserSetting(username, roomName, None, {"joined": True})
|
l = lambda w: w.sendUserSetting(username, roomName, None, {"joined": True})
|
||||||
self.broadcast(watcherProtocol, l)
|
self.broadcast(watcherProtocol, l)
|
||||||
@ -151,7 +152,7 @@ class SyncFactory(Factory):
|
|||||||
self._removeWatcherFromTheRoom(watcherProtocol)
|
self._removeWatcherFromTheRoom(watcherProtocol)
|
||||||
watcher.deactivate()
|
watcher.deactivate()
|
||||||
self._deleteRoomIfEmpty(watcher.room)
|
self._deleteRoomIfEmpty(watcher.room)
|
||||||
print "{0} left server".format(watcher.name)
|
print getMessage("en", "client-left-server-notification").format(watcher.name)
|
||||||
|
|
||||||
def watcherGetUsername(self, watcherProtocol):
|
def watcherGetUsername(self, watcherProtocol):
|
||||||
return self.getWatcher(watcherProtocol).name
|
return self.getWatcher(watcherProtocol).name
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from syncplay import constants
|
from syncplay import constants
|
||||||
|
from syncplay.messages import getMessage
|
||||||
try:
|
try:
|
||||||
from syncplay.ui.GuiConfiguration import GuiConfiguration
|
from syncplay.ui.GuiConfiguration import GuiConfiguration
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -49,19 +50,19 @@ class ConfigurationGetter(object):
|
|||||||
#
|
#
|
||||||
#Watch out for the method self._overrideConfigWithArgs when you're adding custom multi-word command line arguments
|
#Watch out for the method self._overrideConfigWithArgs when you're adding custom multi-word command line arguments
|
||||||
#
|
#
|
||||||
self._argparser = argparse.ArgumentParser(description='Solution to synchronize playback of multiple MPlayer and MPC-HC instances over the network.',
|
self._argparser = argparse.ArgumentParser(description=getMessage("en", "argument-description"),
|
||||||
epilog='If no options supplied values from configuration file will be used')
|
epilog='If no options supplied values from configuration file will be used')
|
||||||
self._argparser.add_argument('--no-gui', action='store_true', help='show no GUI')
|
self._argparser.add_argument('--no-gui', action='store_true', help=getMessage("en", "nogui-argument"))
|
||||||
self._argparser.add_argument('-a', '--host', metavar='hostname', type=str, help='server\'s address')
|
self._argparser.add_argument('-a', '--host', metavar='hostname', type=str, help=getMessage("en", "host-argument"))
|
||||||
self._argparser.add_argument('-n', '--name', metavar='username', type=str, help='desired username')
|
self._argparser.add_argument('-n', '--name', metavar='username', type=str, help=getMessage("en", "name-argument"))
|
||||||
self._argparser.add_argument('-d', '--debug', action='store_true', help='debug mode')
|
self._argparser.add_argument('-d', '--debug', action='store_true', help=getMessage("en", "debug-argument"))
|
||||||
self._argparser.add_argument('-g', '--force-gui-prompt', action='store_true', help='make configuration prompt appear')
|
self._argparser.add_argument('-g', '--force-gui-prompt', action='store_true', help=getMessage("en", "force-gui-prompt-argument"))
|
||||||
self._argparser.add_argument('--no-store', action='store_true', help='don\'t store values in .syncplay')
|
self._argparser.add_argument('--no-store', action='store_true', help=getMessage("en", "no-store-argument"))
|
||||||
self._argparser.add_argument('-r', '--room', metavar='room', type=str, nargs='?', help='default room')
|
self._argparser.add_argument('-r', '--room', metavar='room', type=str, nargs='?', help=getMessage("en", "room-argument"))
|
||||||
self._argparser.add_argument('-p', '--password', metavar='password', type=str, nargs='?', help='server password')
|
self._argparser.add_argument('-p', '--password', metavar='password', type=str, nargs='?', help=getMessage("en", "password-argument"))
|
||||||
self._argparser.add_argument('--player-path', metavar='path', type=str, help='path to your player executable')
|
self._argparser.add_argument('--player-path', metavar='path', type=str, help=getMessage("en", "player-path-argument"))
|
||||||
self._argparser.add_argument('file', metavar='file', type=str, nargs='?', help='file to play')
|
self._argparser.add_argument('file', metavar='file', type=str, nargs='?', help=getMessage("en", "file-argument"))
|
||||||
self._argparser.add_argument('_args', metavar='options', type=str, nargs='*', help='player options, if you need to pass options starting with - prepend them with single \'--\' argument')
|
self._argparser.add_argument('_args', metavar='options', type=str, nargs='*', help=getMessage("en", "args-argument"))
|
||||||
|
|
||||||
def _validateArguments(self):
|
def _validateArguments(self):
|
||||||
for key in self._required:
|
for key in self._required:
|
||||||
@ -72,15 +73,15 @@ class ConfigurationGetter(object):
|
|||||||
elif(self._isMplayerPathAndValid(self._config["playerPath"])):
|
elif(self._isMplayerPathAndValid(self._config["playerPath"])):
|
||||||
self._config["playerType"] = "mplayer"
|
self._config["playerType"] = "mplayer"
|
||||||
else:
|
else:
|
||||||
raise InvalidConfigValue("Player path is not set properly")
|
raise InvalidConfigValue(getMessage("en", "player-path-error"))
|
||||||
elif(key == "host"):
|
elif(key == "host"):
|
||||||
self._config["host"], self._config["port"] = self._splitPortAndHost(self._config["host"])
|
self._config["host"], self._config["port"] = self._splitPortAndHost(self._config["host"])
|
||||||
hostNotValid = (self._config["host"] == "" or self._config["host"] is None)
|
hostNotValid = (self._config["host"] == "" or self._config["host"] is None)
|
||||||
portNotValid = (self._config["port"] == "" or self._config["port"] is None)
|
portNotValid = (self._config["port"] == "" or self._config["port"] is None)
|
||||||
if(hostNotValid or portNotValid):
|
if(hostNotValid or portNotValid):
|
||||||
raise InvalidConfigValue("Hostname can't be empty")
|
raise InvalidConfigValue(getMessage("en", "hostname-empty-error"))
|
||||||
elif(self._config[key] == "" or self._config[key] is None):
|
elif(self._config[key] == "" or self._config[key] is None):
|
||||||
raise InvalidConfigValue("{} can't be empty".format(key))
|
raise InvalidConfigValue(getMessage("en", "empty-error").format(key))
|
||||||
|
|
||||||
def _overrideConfigWithArgs(self, args):
|
def _overrideConfigWithArgs(self, args):
|
||||||
for key, val in vars(args).items():
|
for key, val in vars(args).items():
|
||||||
@ -176,7 +177,7 @@ class ConfigurationGetter(object):
|
|||||||
|
|
||||||
def _promptForMissingArguments(self):
|
def _promptForMissingArguments(self):
|
||||||
if(self._config['noGui']):
|
if(self._config['noGui']):
|
||||||
print "Some necessary arguments are missing, refer to --help"
|
print getMessage("en", "arguments-missing-error")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
elif(GuiConfiguration):
|
elif(GuiConfiguration):
|
||||||
return GuiConfiguration(self._config).getProcessedConfiguration()
|
return GuiConfiguration(self._config).getProcessedConfiguration()
|
||||||
@ -228,8 +229,8 @@ class ServerConfigurationGetter(object):
|
|||||||
return self._args
|
return self._args
|
||||||
|
|
||||||
def _prepareArgParser(self):
|
def _prepareArgParser(self):
|
||||||
self._argparser = argparse.ArgumentParser(description='Solution to synchronize playback of multiple MPlayer and MPC-HC instances over the network. Server instance',
|
self._argparser = argparse.ArgumentParser(description=getMessage("en", "server-argument-description"),
|
||||||
epilog='If no options supplied _config values will be used')
|
epilog=getMessage("en", "argument-epilog"))
|
||||||
self._argparser.add_argument('--port', metavar='port', type=str, nargs='?', help='server TCP port')
|
self._argparser.add_argument('--port', metavar='port', type=str, nargs='?', help=getMessage("en", "server-port-argument"))
|
||||||
self._argparser.add_argument('--password', metavar='password', type=str, nargs='?', help='server password')
|
self._argparser.add_argument('--password', metavar='password', type=str, nargs='?', help=getMessage("en", "password-argument"))
|
||||||
self._argparser.add_argument('--isolate-rooms', action='store_true', help='should rooms be isolated?')
|
self._argparser.add_argument('--isolate-rooms', action='store_true', help=getMessage("en", "server-isolate-room-argument"))
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import pygtk
|
import pygtk
|
||||||
import os
|
import os
|
||||||
from syncplay import constants
|
from syncplay import constants
|
||||||
|
from syncplay.messages import getMessage
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk
|
import gtk
|
||||||
gtk.set_interactive(False)
|
gtk.set_interactive(False)
|
||||||
@ -41,11 +42,11 @@ class GuiConfiguration:
|
|||||||
else:
|
else:
|
||||||
host = config['host']+":"+str(config['port'])
|
host = config['host']+":"+str(config['port'])
|
||||||
|
|
||||||
self.hostEntry = self._addLabeledEntryToVbox('Host: ', host, vbox, lambda __, _: self._saveDataAndLeave())
|
self.hostEntry = self._addLabeledEntryToVbox(getMessage("en", "host-label"), host, vbox, lambda __, _: self._saveDataAndLeave())
|
||||||
self.userEntry = self._addLabeledEntryToVbox('Username: ', config['name'], vbox, lambda __, _: self._saveDataAndLeave())
|
self.userEntry = self._addLabeledEntryToVbox(getMessage("en", "username-label"), config['name'], vbox, lambda __, _: self._saveDataAndLeave())
|
||||||
self.roomEntry = self._addLabeledEntryToVbox('Default room (optional): ', config['room'], vbox, lambda __, _: self._saveDataAndLeave())
|
self.roomEntry = self._addLabeledEntryToVbox(getMessage("en", "room-label"), config['room'], vbox, lambda __, _: self._saveDataAndLeave())
|
||||||
self.passEntry = self._addLabeledEntryToVbox('Server password (optional): ', config['password'], vbox, lambda __, _: self._saveDataAndLeave())
|
self.passEntry = self._addLabeledEntryToVbox(getMessage("en", "password-label"), config['password'], vbox, lambda __, _: self._saveDataAndLeave())
|
||||||
self.mpcEntry = self._addLabeledEntryToVbox('Path to player executable: ', self._tryToFillUpMpcPath(config['playerPath']), vbox, lambda __, _: self._saveDataAndLeave())
|
self.mpcEntry = self._addLabeledEntryToVbox(getMessage("en", "path-label"), self._tryToFillUpMpcPath(config['playerPath']), vbox, lambda __, _: self._saveDataAndLeave())
|
||||||
|
|
||||||
def _tryToFillUpMpcPath(self, playerPath):
|
def _tryToFillUpMpcPath(self, playerPath):
|
||||||
if(playerPath == None):
|
if(playerPath == None):
|
||||||
|
|||||||
@ -6,6 +6,7 @@ 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
|
||||||
class ConsoleUI(threading.Thread):
|
class ConsoleUI(threading.Thread):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.promptMode = threading.Event()
|
self.promptMode = threading.Event()
|
||||||
@ -109,14 +110,14 @@ class ConsoleUI(threading.Thread):
|
|||||||
if(self._tryAdvancedCommands(data)):
|
if(self._tryAdvancedCommands(data)):
|
||||||
return
|
return
|
||||||
if (command.group('command') not in constants.COMMANDS_HELP):
|
if (command.group('command') not in constants.COMMANDS_HELP):
|
||||||
self.showMessage("Unrecognized command")
|
self.showMessage(getMessage("en", "unrecognized-command-notification"))
|
||||||
self.showMessage("Available commands:", True)
|
self.showMessage(getMessage("en", "commandlist-notification"), True)
|
||||||
self.showMessage("\tr [name] - change room", True)
|
self.showMessage(getMessage("en", "commandlist-notification/room"), True)
|
||||||
self.showMessage("\tl - show user list", True)
|
self.showMessage(getMessage("en", "commandlist-notification/list"), True)
|
||||||
self.showMessage("\tu - undo last seek", True)
|
self.showMessage(getMessage("en", "commandlist-notification/undo"), True)
|
||||||
self.showMessage("\tp - toggle pause", True)
|
self.showMessage(getMessage("en", "commandlist-notification/pause"), True)
|
||||||
self.showMessage("\t[s][+-]time - seek to the given value of time, if + or - is not specified it's absolute time in seconds or min:sec", True)
|
self.showMessage(getMessage("en", "commandlist-notification/seek"), True)
|
||||||
self.showMessage("\th - this help", True)
|
self.showMessage(getMessage("en", "commandlist-notification/help"), True)
|
||||||
self.showMessage("Syncplay version: {}".format(syncplay.version), True)
|
self.showMessage("Syncplay version: {}".format(syncplay.version), True)
|
||||||
self.showMessage("More info available at: {}".format(syncplay.projectURL), True)
|
self.showMessage("More info available at: {}".format(syncplay.projectURL), True)
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import time
|
|||||||
import re
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
from syncplay import constants
|
from syncplay import constants
|
||||||
|
from syncplay.messages import getMessage
|
||||||
|
|
||||||
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None):
|
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None):
|
||||||
"""Retry calling the decorated function using an exponential backoff.
|
"""Retry calling the decorated function using an exponential backoff.
|
||||||
@ -33,7 +34,7 @@ def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None):
|
|||||||
break
|
break
|
||||||
except ExceptionToCheck, e:
|
except ExceptionToCheck, e:
|
||||||
if logger:
|
if logger:
|
||||||
msg = "%s, Retrying in %d seconds..." % (str(e), mdelay)
|
msg = getMessage("en", "retrying-notification") % (str(e), mdelay)
|
||||||
logger.warning(msg)
|
logger.warning(msg)
|
||||||
time.sleep(mdelay)
|
time.sleep(mdelay)
|
||||||
mtries -= 1
|
mtries -= 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user