Improve version checking
This commit is contained in:
parent
e3255d1b92
commit
c8e3426547
@ -436,14 +436,14 @@ class SyncplayClient(object):
|
||||
def requireMinVersionDecorator(f):
|
||||
@wraps(f)
|
||||
def wrapper(self, *args, **kwds):
|
||||
if int(self.serverVersion.replace(".", "")) < int(minVersion.replace(".", "")):
|
||||
if not utils.meetsMinVersion(self.serverVersion,minVersion):
|
||||
self.ui.showErrorMessage(u"This feature is not supported by the server. The feature requires a server running Syncplay {}+, but the server is running Syncplay {}.".format(minVersion, self.serverVersion))
|
||||
return
|
||||
return f(self, *args, **kwds)
|
||||
return wrapper
|
||||
return requireMinVersionDecorator
|
||||
|
||||
@requireMinServerVersion("1.3.0")
|
||||
@requireMinServerVersion(constants.CONTROLLED_ROOMS_MIN_VERSION)
|
||||
def createControlledRoom(self, roomName):
|
||||
controlPassword = utils.RandomStringGenerator.generate_room_password()
|
||||
self.ui.showMessage(u"Attempting to create controlled room '{}' with password '{}'...".format(roomName, controlPassword))
|
||||
@ -463,7 +463,7 @@ class SyncplayClient(object):
|
||||
else:
|
||||
return ""
|
||||
|
||||
@requireMinServerVersion("1.3.0")
|
||||
@requireMinServerVersion(constants.CONTROLLED_ROOMS_MIN_VERSION)
|
||||
def identifyAsController(self, controlPassword):
|
||||
controlPassword = self.stripControlPassword(controlPassword)
|
||||
self.ui.showMessage(getMessage("identifying-as-controller-notification").format(controlPassword))
|
||||
|
||||
@ -52,6 +52,7 @@ COMMANDS_AUTH = ['a','auth']
|
||||
MPC_MIN_VER = "1.6.4"
|
||||
VLC_MIN_VERSION = "2.0.0"
|
||||
VLC_INTERFACE_MIN_VERSION = "0.2.1"
|
||||
CONTROLLED_ROOMS_MIN_VERSION = "1.3.0"
|
||||
MPC_PATHS = [
|
||||
r"C:\Program Files (x86)\MPC-HC\mpc-hc.exe",
|
||||
r"C:\Program Files\MPC-HC\mpc-hc.exe",
|
||||
|
||||
@ -11,7 +11,7 @@ import codecs
|
||||
import os
|
||||
from string import Template
|
||||
import argparse
|
||||
from syncplay.utils import RoomPasswordProvider, NotControlledRoom, RandomStringGenerator
|
||||
from syncplay.utils import RoomPasswordProvider, NotControlledRoom, RandomStringGenerator, meetsMinVersion
|
||||
|
||||
class SyncFactory(Factory):
|
||||
def __init__(self, password='', motdFilePath=None, isolateRooms=False, salt=None):
|
||||
@ -42,7 +42,7 @@ class SyncFactory(Factory):
|
||||
def getMotd(self, userIp, username, room, clientVersion):
|
||||
oldClient = False
|
||||
if constants.WARN_OLD_CLIENTS:
|
||||
if int(clientVersion.replace(".", "")) < int(constants.RECENT_CLIENT_THRESHOLD.replace(".", "")):
|
||||
if not meetsMinVersion(clientVersion, constants.RECENT_CLIENT_THRESHOLD):
|
||||
oldClient = True
|
||||
if self._motdFilePath and os.path.isfile(self._motdFilePath):
|
||||
tmpl = codecs.open(self._motdFilePath, "r", "utf-8-sig").read()
|
||||
|
||||
@ -210,6 +210,13 @@ def sameFileduration (duration1, duration2):
|
||||
else:
|
||||
return False
|
||||
|
||||
def meetsMinVersion(version, minVersion):
|
||||
def versiontotuple(ver):
|
||||
return tuple(map(int, ver.split(".")))
|
||||
versionTuple = versiontotuple(version)
|
||||
minVersionTuple = versiontotuple(minVersion)
|
||||
return versionTuple >= minVersionTuple
|
||||
|
||||
class RoomPasswordProvider(object):
|
||||
CONTROLLED_ROOM_REGEX = re.compile("^\+(.*):(\w{12})$")
|
||||
PASSWORD_REGEX = re.compile("[A-Z]{2}-\d{3}-\d{3}")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user