Skip to content

Commit

Permalink
Merge pull request Syncplay#188 from sometoby/master
Browse files Browse the repository at this point in the history
  • Loading branch information
albertosottile committed Jun 9, 2018
2 parents 477dc37 + 9349b88 commit 1247151
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -36,7 +36,7 @@ install:

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
Expand All @@ -51,4 +51,4 @@ deploy:
file: "bintray.json"
user: alby128
key:
secure: "I9J3lgHyDoLzuGkjjMuYIk3ZI7Lszn2AG1H6lxIU3SXYaBpbLK+BHXotW0IsSxK5idCK8uszeA2svVipepwtCc9xJYEAlEYLVBgO9BpgTdQid9XjvI1eLDG3+iw0ew+FwEqaYwYbFHfnnQhVzIwBq353kl9ksgDMXi1uREpUk/L3HfVOUV3rDF6mgOPwAUJHBc3d56IVX1yQunM7NwJuswFrBMESauAlzw/C1gWDAuWJ5iJfnFz/4RBDa3C1sZdFmNnkuQEI332HzoMialMGyEP5gE8l0dmXBtFHpE1acgEZ+l1hVz9OsI2/dyICkjYFRLWF2tmxAk4DDF3jTsIRRsxpQo25XGKfvd0FrbN8Zqw8Yb0a5/WPP2E2ERGGLDxqTfkybYPv35utbtHEd4IZTX0Yv/GnmSwFa39+a7RDNhgFJWDR8XUX4Srd9CBron+36KrS+zY2Nn0c36YBxyAocw8qQ/pXmS15sQxSq2pi+GASyhemN546Gz2jbc3W/Ybp85iQ9Py/7Q1wUyYQVvJqEPL0K+/ioDSr4bDWbtqBLpUPlOYOvR4MPGCpqrfjJslpPPKBN8lD0BV2LYZEW6Bip0e8CsrFhecD1atNyWClaPoC0aikH3jpFfQYJOyQ6zghqpHSC+/S3HuGV/P8WCVBpC3TTrk0/TacwZwch3yhK9A="
secure: "I9J3lgHyDoLzuGkjjMuYIk3ZI7Lszn2AG1H6lxIU3SXYaBpbLK+BHXotW0IsSxK5idCK8uszeA2svVipepwtCc9xJYEAlEYLVBgO9BpgTdQid9XjvI1eLDG3+iw0ew+FwEqaYwYbFHfnnQhVzIwBq353kl9ksgDMXi1uREpUk/L3HfVOUV3rDF6mgOPwAUJHBc3d56IVX1yQunM7NwJuswFrBMESauAlzw/C1gWDAuWJ5iJfnFz/4RBDa3C1sZdFmNnkuQEI332HzoMialMGyEP5gE8l0dmXBtFHpE1acgEZ+l1hVz9OsI2/dyICkjYFRLWF2tmxAk4DDF3jTsIRRsxpQo25XGKfvd0FrbN8Zqw8Yb0a5/WPP2E2ERGGLDxqTfkybYPv35utbtHEd4IZTX0Yv/GnmSwFa39+a7RDNhgFJWDR8XUX4Srd9CBron+36KrS+zY2Nn0c36YBxyAocw8qQ/pXmS15sQxSq2pi+GASyhemN546Gz2jbc3W/Ybp85iQ9Py/7Q1wUyYQVvJqEPL0K+/ioDSr4bDWbtqBLpUPlOYOvR4MPGCpqrfjJslpPPKBN8lD0BV2LYZEW6Bip0e8CsrFhecD1atNyWClaPoC0aikH3jpFfQYJOyQ6zghqpHSC+/S3HuGV/P8WCVBpC3TTrk0/TacwZwch3yhK9A="
3 changes: 1 addition & 2 deletions syncplay/constants.py
Expand Up @@ -8,8 +8,7 @@
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
Expand Down
38 changes: 23 additions & 15 deletions syncplay/ui/ConfigurationGetter.py
Expand Up @@ -322,21 +322,29 @@ def _checkForPortableFile(self):

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)

return configFile
if configFile:
return configFile
for name in constants.CONFIG_NAMES:
configFile = self._expandConfigPath(name, xdg = False)
if os.path.isfile(configFile):
return configFile
return self._expandConfigPath()

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):
parser = SafeConfigParserUnicode()
Expand Down

0 comments on commit 1247151

Please sign in to comment.