Merge pull request #188 from sometoby/master

This commit is contained in:
Alberto Sottile 2018-06-09 12:31:32 +02:00
commit 1247151fc3
3 changed files with 25 additions and 18 deletions

View File

@ -36,7 +36,7 @@ install:
before_deploy: before_deploy:
#- travis/cache-homebrew #- travis/cache-homebrew
- pip2 install dmgbuild - pip install dmgbuild
- mkdir dist_dmg - mkdir dist_dmg
- mv resources/macos_vlc_install.command resources/.macos_vlc_install.command - mv resources/macos_vlc_install.command resources/.macos_vlc_install.command
- mv resources/lua/intf/syncplay.lua resources/lua/intf/.syncplay.lua - mv resources/lua/intf/syncplay.lua resources/lua/intf/.syncplay.lua

View File

@ -8,8 +8,7 @@ MPC_OSD_POSITION = 1 #Right corner, 1 for left
MPLAYER_OSD_LEVEL = 1 MPLAYER_OSD_LEVEL = 1
UI_TIME_FORMAT = "[%X] " UI_TIME_FORMAT = "[%X] "
CONFIG_NAMES = [".syncplay", "syncplay.ini"] #Syncplay searches first to last CONFIG_NAMES = [".syncplay", "syncplay.ini"] #Syncplay searches first to last
DEFAULT_CONFIG_NAME_WINDOWS = "syncplay.ini" DEFAULT_CONFIG_NAME = "syncplay.ini"
DEFAULT_CONFIG_NAME_LINUX = ".syncplay"
RECENT_CLIENT_THRESHOLD = "1.5.3" #This and higher considered 'recent' clients (no warnings) RECENT_CLIENT_THRESHOLD = "1.5.3" #This and higher considered 'recent' clients (no warnings)
WARN_OLD_CLIENTS = True #Use MOTD to inform old clients to upgrade WARN_OLD_CLIENTS = True #Use MOTD to inform old clients to upgrade
LIST_RELATIVE_CONFIGS = True # Print list of relative configs loaded LIST_RELATIVE_CONFIGS = True # Print list of relative configs loaded

View File

@ -322,21 +322,29 @@ class ConfigurationGetter(object):
def _getConfigurationFilePath(self): def _getConfigurationFilePath(self):
configFile = self._checkForPortableFile() configFile = self._checkForPortableFile()
if not configFile: if configFile:
for name in constants.CONFIG_NAMES: return configFile
if configFile and os.path.isfile(configFile): for name in constants.CONFIG_NAMES:
break configFile = self._expandConfigPath(name, xdg = False)
if os.name <> 'nt': if os.path.isfile(configFile):
configFile = os.path.join(os.getenv('HOME', '.'), name) return configFile
else: return self._expandConfigPath()
configFile = os.path.join(os.getenv('APPDATA', '.'), name)
if configFile and not os.path.isfile(configFile):
if os.name <> 'nt':
configFile = os.path.join(os.getenv('HOME', '.'), constants.DEFAULT_CONFIG_NAME_LINUX)
else:
configFile = os.path.join(os.getenv('APPDATA', '.'), constants.DEFAULT_CONFIG_NAME_WINDOWS)
return configFile def _expandConfigPath(self, name = None, xdg = True):
if os.name != 'nt':
if xdg:
prefix = self._getXdgConfigHome()
else:
prefix = os.getenv('HOME', '.')
else:
prefix = os.getenv('APPDATA', '.')
return os.path.join(prefix, name or constants.DEFAULT_CONFIG_NAME)
def _getXdgConfigHome(self):
path = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
if not os.path.isdir(path):
os.mkdir(path, 0o755)
return path
def _parseConfigFile(self, iniPath, createConfig=True): def _parseConfigFile(self, iniPath, createConfig=True):
parser = SafeConfigParserUnicode() parser = SafeConfigParserUnicode()