Added syncplay.ini as an optional config name

This commit is contained in:
Uriziel 2014-02-20 22:04:17 +01:00
parent 79a94c08d6
commit 88a68b11e6
2 changed files with 18 additions and 13 deletions

View File

@ -5,7 +5,7 @@ OSD_WARNING_MESSAGE_DURATION = 15
MPC_OSD_POSITION = 2 #Right corner, 1 for left
MPLAYER_OSD_LEVEL = 1
UI_TIME_FORMAT = "[%X] "
DEFAULT_CONFIG_NAME = ".syncplay"
DEFAULT_CONFIG_NAMES = [".syncplay", "syncplay.ini"]
#Changing these might be ok
REWIND_THRESHOLD = 4

View File

@ -141,19 +141,23 @@ class ConfigurationGetter(object):
if ':' in host:
host, port = host.split(':', 1)
return host, int(port)
def _checkForPortableFile(self):
path = utils.findWorkingDir()
if(os.path.isfile(os.path.join(path, constants.DEFAULT_CONFIG_NAME))):
return os.path.join(path, constants.DEFAULT_CONFIG_NAME)
for name in constants.DEFAULT_CONFIG_NAMES:
if(os.path.isfile(os.path.join(path, name))):
return os.path.join(path, name)
def _getConfigurationFilePath(self):
configFile = self._checkForPortableFile()
if(not configFile):
if(os.name <> 'nt'):
configFile = os.path.join(os.getenv('HOME', '.'), constants.DEFAULT_CONFIG_NAME)
else:
configFile = os.path.join(os.getenv('APPDATA', '.'), constants.DEFAULT_CONFIG_NAME)
if not configFile:
for name in constants.DEFAULT_CONFIG_NAMES:
if(configFile and os.path.isfile(configFile)):
break
if(os.name <> 'nt'):
configFile = os.path.join(os.getenv('HOME', '.'), name)
else:
configFile = os.path.join(os.getenv('APPDATA', '.'), name)
return configFile
def _parseConfigFile(self, iniPath, createConfig = True):
@ -242,9 +246,10 @@ class ConfigurationGetter(object):
def _loadRelativeConfiguration(self):
locations = self.__getRelativeConfigLocations()
for location in locations:
path = location + os.path.sep + constants.DEFAULT_CONFIG_NAME
self._parseConfigFile(path, createConfig = False)
self._checkConfig()
for name in constants.DEFAULT_CONFIG_NAMES:
path = location + os.path.sep + name
self._parseConfigFile(path, createConfig = False)
self._checkConfig()
def getConfiguration(self):
iniPath = self._getConfigurationFilePath()