From 3d7c3ff53873e3cb21a30897d3665ccd9656e969 Mon Sep 17 00:00:00 2001 From: Flisk Date: Tue, 5 Jun 2018 17:31:39 +0200 Subject: [PATCH 1/3] Refactor config path logic --- syncplay/ui/ConfigurationGetter.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/syncplay/ui/ConfigurationGetter.py b/syncplay/ui/ConfigurationGetter.py index d1bbe81..b414e96 100755 --- a/syncplay/ui/ConfigurationGetter.py +++ b/syncplay/ui/ConfigurationGetter.py @@ -322,21 +322,22 @@ class ConfigurationGetter(object): def _getConfigurationFilePath(self): configFile = self._checkForPortableFile() - if not configFile: - for name in constants.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) - 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) + if configFile: + return configFile + for name in constants.CONFIG_NAMES: + configFile = self._expandConfigPath(name) + if os.path.isfile(configFile): + return configFile + return self._expandConfigPath() - return configFile + def _expandConfigPath(self, name = None): + if os.name != 'nt': + prefix = os.getenv('HOME', '.') + default_name = constants.DEFAULT_CONFIG_NAME_LINUX + else: + prefix = os.getenv('APPDATA', '.') + default_name = constants.DEFAULT_CONFIG_NAME_WINDOWS + return os.path.join(prefix, name or default_name) def _parseConfigFile(self, iniPath, createConfig=True): parser = SafeConfigParserUnicode() From dbe490a5ee57554bb01db83e89cf94c488052628 Mon Sep 17 00:00:00 2001 From: Flisk Date: Tue, 5 Jun 2018 17:52:27 +0200 Subject: [PATCH 2/3] Default to XDG_CONFIG_HOME on non-'nt' platforms The default config path on Linux becomes `~/.config/syncplay.ini`, provided the user hasn't changed her $XDG_CONFIG_HOME. Existing installations continue to read their config from `~/.syncplay`, should that file exist. --- syncplay/constants.py | 3 +-- syncplay/ui/ConfigurationGetter.py | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/syncplay/constants.py b/syncplay/constants.py index 122b491..f999ed0 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -8,8 +8,7 @@ MPC_OSD_POSITION = 1 #Right corner, 1 for left MPLAYER_OSD_LEVEL = 1 UI_TIME_FORMAT = "[%X] " CONFIG_NAMES = [".syncplay", "syncplay.ini"] #Syncplay searches first to last -DEFAULT_CONFIG_NAME_WINDOWS = "syncplay.ini" -DEFAULT_CONFIG_NAME_LINUX = ".syncplay" +DEFAULT_CONFIG_NAME = "syncplay.ini" 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 LIST_RELATIVE_CONFIGS = True # Print list of relative configs loaded diff --git a/syncplay/ui/ConfigurationGetter.py b/syncplay/ui/ConfigurationGetter.py index b414e96..b251d26 100755 --- a/syncplay/ui/ConfigurationGetter.py +++ b/syncplay/ui/ConfigurationGetter.py @@ -325,19 +325,26 @@ class ConfigurationGetter(object): if configFile: return configFile for name in constants.CONFIG_NAMES: - configFile = self._expandConfigPath(name) + configFile = self._expandConfigPath(name, xdg = False) if os.path.isfile(configFile): return configFile return self._expandConfigPath() - def _expandConfigPath(self, name = None): + def _expandConfigPath(self, name = None, xdg = True): if os.name != 'nt': - prefix = os.getenv('HOME', '.') - default_name = constants.DEFAULT_CONFIG_NAME_LINUX + if xdg: + prefix = self._getXdgConfigHome() + else: + prefix = os.getenv('HOME', '.') else: prefix = os.getenv('APPDATA', '.') - default_name = constants.DEFAULT_CONFIG_NAME_WINDOWS - return os.path.join(prefix, name or default_name) + 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): parser = SafeConfigParserUnicode() From 2c8f64d0a2db3c960c52871161b11639ff3bbda4 Mon Sep 17 00:00:00 2001 From: albertosottile Date: Tue, 5 Jun 2018 18:30:00 +0200 Subject: [PATCH 3/3] Switch Travis image to xcode7.3 (macOS 10.11+) --- .travis.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 631d11f..150efe5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,26 @@ language: objective-c -osx_image: xcode6.4 +osx_image: xcode7.3 branches: only: - master script: -- python2 buildPy2app.py py2app fix +- python buildPy2app.py py2app fix before_install: - brew update -- travis/download-homebrew -- export PATH="/usr/local/opt/python@2/bin:$PATH" -- travis/download-python - brew tap cartr/qt4 - brew tap-pin cartr/qt4 - brew install pyside install: - export QT_PREFERRED_BINDING="PySide" -- pip2 install twisted appnope pyobjc py2app +- pip install twisted appnope pyobjc py2app before_deploy: #- travis/cache-homebrew -- pip2 install dmgbuild +- pip install dmgbuild - mkdir dist_dmg - mv resources/macos_vlc_install.command resources/.macos_vlc_install.command - mv resources/lua/intf/syncplay.lua resources/lua/intf/.syncplay.lua