diff options
author | drebs <drebs@leap.se> | 2013-02-09 22:27:22 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-02-09 22:27:22 -0200 |
commit | 46a3373295a683db9b66c233b07a7a948b8147bc (patch) | |
tree | 410a47871bfd8654ddabbb53f3c29a89c1550e71 /src/leap/base/config.py | |
parent | e726f3df7c7efbe4069846468ffdbed6829ccfc4 (diff) | |
parent | b376948ccd59aa02022123102eaae359a536e4e6 (diff) |
Merge branch 'develop' into feature/soledad-api
Diffstat (limited to 'src/leap/base/config.py')
-rw-r--r-- | src/leap/base/config.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/leap/base/config.py b/src/leap/base/config.py index e235e5c3..d796bcf1 100644 --- a/src/leap/base/config.py +++ b/src/leap/base/config.py @@ -4,6 +4,7 @@ Configuration Base Class import grp import json import logging +import re import socket import time import os @@ -11,6 +12,7 @@ import os logger = logging.getLogger(name=__name__) from dateutil import parser as dateparser +from xdg import BaseDirectory import requests from leap.base import exceptions @@ -279,15 +281,16 @@ def get_config_dir(): @rparam: config path @rtype: string """ - # TODO - # check for $XDG_CONFIG_HOME var? - # get a more sensible path for win/mac - # kclair: opinion? ^^ - - return os.path.expanduser( - os.path.join('~', - '.config', - 'leap')) + home = os.path.expanduser("~") + if re.findall("leap_tests-[_a-zA-Z0-9]{6}", home): + # we're inside a test! :) + return os.path.join(home, ".config/leap") + else: + # XXX dirspec is cross-platform, + # we should borrow some of those + # routines for osx/win and wrap this call. + return os.path.join(BaseDirectory.xdg_config_home, + 'leap') def get_config_file(filename, folder=None): @@ -333,7 +336,11 @@ def validate_ip(ip_str): def get_username(): - return os.getlogin() + try: + return os.getlogin() + except OSError as e: + import pwd + return pwd.getpwuid(os.getuid())[0] def get_groupname(): |