Move filePath check to getFilePathErrors
This commit is contained in:
parent
07f0a4a426
commit
45e576e4f2
@ -89,7 +89,19 @@ class BasePlayer(object):
|
||||
@staticmethod
|
||||
def openCustomOpenDialog(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
'''
|
||||
@type filePath: string
|
||||
@return errorMessage: string
|
||||
|
||||
Checks if the player has any problems with the given file (or lack of file)
|
||||
If a problem is detected then it returns the error message
|
||||
If the file is fine then it returns None
|
||||
'''
|
||||
@staticmethod
|
||||
def getFilePathErrors(filePath):
|
||||
raise NotImplementedError()
|
||||
|
||||
class DummyPlayer(BasePlayer):
|
||||
|
||||
@staticmethod
|
||||
@ -107,3 +119,7 @@ class DummyPlayer(BasePlayer):
|
||||
@staticmethod
|
||||
def getExpandedPath(path):
|
||||
return path
|
||||
|
||||
@staticmethod
|
||||
def getFilePathErrors(filePath):
|
||||
return None
|
||||
|
||||
@ -332,6 +332,10 @@ class MPCHCAPIPlayer(BasePlayer):
|
||||
self.__versionUpdate.set()
|
||||
self._mpcApi.sendRawCommand(MpcHcApi.CMD_CLOSEAPP, "")
|
||||
|
||||
@staticmethod
|
||||
def getFilePathErrors(filePath):
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def run(client, playerPath, filePath, args):
|
||||
args.extend(['/open', '/new'])
|
||||
|
||||
@ -212,6 +212,11 @@ class MplayerPlayer(BasePlayer):
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def getFilePathErrors(filePath):
|
||||
if not filePath:
|
||||
return getMessage("no-file-path-config-error")
|
||||
|
||||
@staticmethod
|
||||
def getExpandedPath(playerPath):
|
||||
if not os.path.isfile(playerPath):
|
||||
|
||||
@ -200,6 +200,10 @@ class VlcPlayer(BasePlayer):
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def getFilePathErrors(filePath):
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def getIconPath(path):
|
||||
return constants.VLC_ICONPATH
|
||||
|
||||
@ -145,9 +145,9 @@ class ConfigurationGetter(object):
|
||||
self._config["playerClass"] = player
|
||||
else:
|
||||
raise InvalidConfigValue(getMessage("player-path-config-error"))
|
||||
if player.__name__ in ['MpvPlayer', 'MplayerPlayer']:
|
||||
if not self._config['file']:
|
||||
raise InvalidConfigValue(getMessage("no-file-path-config-error"))
|
||||
fileErrors = player.getFilePathErrors(self._config['file'] if self._config['file'] else None)
|
||||
if fileErrors:
|
||||
raise InvalidConfigValue(fileErrors)
|
||||
elif key == "host":
|
||||
self._config["host"], self._config["port"] = self._splitPortAndHost(self._config["host"])
|
||||
hostNotValid = (self._config["host"] == "" or self._config["host"] is None)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user