Move filePath check to getFilePathErrors
This commit is contained in:
parent
07f0a4a426
commit
45e576e4f2
@ -90,6 +90,18 @@ class BasePlayer(object):
|
|||||||
def openCustomOpenDialog(self):
|
def openCustomOpenDialog(self):
|
||||||
raise NotImplementedError()
|
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):
|
class DummyPlayer(BasePlayer):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -107,3 +119,7 @@ class DummyPlayer(BasePlayer):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def getExpandedPath(path):
|
def getExpandedPath(path):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getFilePathErrors(filePath):
|
||||||
|
return None
|
||||||
|
|||||||
@ -332,6 +332,10 @@ class MPCHCAPIPlayer(BasePlayer):
|
|||||||
self.__versionUpdate.set()
|
self.__versionUpdate.set()
|
||||||
self._mpcApi.sendRawCommand(MpcHcApi.CMD_CLOSEAPP, "")
|
self._mpcApi.sendRawCommand(MpcHcApi.CMD_CLOSEAPP, "")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getFilePathErrors(filePath):
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run(client, playerPath, filePath, args):
|
def run(client, playerPath, filePath, args):
|
||||||
args.extend(['/open', '/new'])
|
args.extend(['/open', '/new'])
|
||||||
|
|||||||
@ -212,6 +212,11 @@ class MplayerPlayer(BasePlayer):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getFilePathErrors(filePath):
|
||||||
|
if not filePath:
|
||||||
|
return getMessage("no-file-path-config-error")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getExpandedPath(playerPath):
|
def getExpandedPath(playerPath):
|
||||||
if not os.path.isfile(playerPath):
|
if not os.path.isfile(playerPath):
|
||||||
|
|||||||
@ -200,6 +200,10 @@ class VlcPlayer(BasePlayer):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getFilePathErrors(filePath):
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getIconPath(path):
|
def getIconPath(path):
|
||||||
return constants.VLC_ICONPATH
|
return constants.VLC_ICONPATH
|
||||||
|
|||||||
@ -145,9 +145,9 @@ class ConfigurationGetter(object):
|
|||||||
self._config["playerClass"] = player
|
self._config["playerClass"] = player
|
||||||
else:
|
else:
|
||||||
raise InvalidConfigValue(getMessage("player-path-config-error"))
|
raise InvalidConfigValue(getMessage("player-path-config-error"))
|
||||||
if player.__name__ in ['MpvPlayer', 'MplayerPlayer']:
|
fileErrors = player.getFilePathErrors(self._config['file'] if self._config['file'] else None)
|
||||||
if not self._config['file']:
|
if fileErrors:
|
||||||
raise InvalidConfigValue(getMessage("no-file-path-config-error"))
|
raise InvalidConfigValue(fileErrors)
|
||||||
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)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user