Commit c349971d authored by mmoss@chromium.org's avatar mmoss@chromium.org

Fix some path processing to work better on Windows.

R=hinoka@chromium.org
BUG=555036

Review URL: https://codereview.chromium.org/1471973004

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@297698 0039d316-1c4b-4281-b951-d872f2087c98
parent 13ccc772
...@@ -255,7 +255,8 @@ class SvnConfig(object): ...@@ -255,7 +255,8 @@ class SvnConfig(object):
if sys.platform == 'win32': if sys.platform == 'win32':
self.svn_config_dir = os.path.join(os.environ['APPDATA'], 'Subversion') self.svn_config_dir = os.path.join(os.environ['APPDATA'], 'Subversion')
else: else:
self.svn_config_dir = os.path.join(os.environ['HOME'], '.subversion') self.svn_config_dir = os.path.expanduser(
os.path.join('~', '.subversion'))
svn_config_file = os.path.join(self.svn_config_dir, 'config') svn_config_file = os.path.join(self.svn_config_dir, 'config')
parser = ConfigParser.SafeConfigParser() parser = ConfigParser.SafeConfigParser()
if os.path.isfile(svn_config_file): if os.path.isfile(svn_config_file):
......
...@@ -22,7 +22,7 @@ import re ...@@ -22,7 +22,7 @@ import re
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
GCLIENT = os.path.join(SCRIPT_DIR, 'gclient.py') GCLIENT = os.path.join(SCRIPT_DIR, 'gclient.py')
TARGET_DIR = os.path.expanduser('~/.chrome-infra') TARGET_DIR = os.path.expanduser(os.path.join('~', '.chrome-infra'))
INFRA_DIR = os.path.join(TARGET_DIR, 'infra') INFRA_DIR = os.path.join(TARGET_DIR, 'infra')
......
...@@ -71,15 +71,9 @@ def CheckHomeForFile(filename): ...@@ -71,15 +71,9 @@ def CheckHomeForFile(filename):
"""Checks the users home dir for the existence of the given file. Returns """Checks the users home dir for the existence of the given file. Returns
the path to the file if it's there, or None if it is not. the path to the file if it's there, or None if it is not.
""" """
home_vars = ['HOME'] full_path = os.path.expanduser(os.path.join('~', filename))
if sys.platform in ('cygwin', 'win32'): if os.path.exists(full_path):
home_vars.append('USERPROFILE') return full_path
for home_var in home_vars:
home = os.getenv(home_var)
if home != None:
full_path = os.path.join(home, filename)
if os.path.exists(full_path):
return full_path
return None return None
......
...@@ -97,7 +97,7 @@ class NetrcAuthenticator(Authenticator): ...@@ -97,7 +97,7 @@ class NetrcAuthenticator(Authenticator):
@staticmethod @staticmethod
def _get_netrc(): def _get_netrc():
path = '_netrc' if sys.platform.startswith('win') else '.netrc' path = '_netrc' if sys.platform.startswith('win') else '.netrc'
path = os.path.join(os.environ['HOME'], path) path = os.path.expanduser(os.path.join('~', path))
try: try:
return netrc.netrc(path) return netrc.netrc(path)
except IOError: except IOError:
......
...@@ -233,7 +233,7 @@ if (ver[0], ver[1]) < MIN_PYTHON_VERSION: ...@@ -233,7 +233,7 @@ if (ver[0], ver[1]) < MIN_PYTHON_VERSION:
% sys.version.split(' ')[0], file=sys.stderr) % sys.version.split(' ')[0], file=sys.stderr)
sys.exit(1) sys.exit(1)
home_dot_repo = os.path.expanduser('~/.repoconfig') home_dot_repo = os.path.expanduser(os.path.join('~','.repoconfig'))
gpg_dir = os.path.join(home_dot_repo, 'gnupg') gpg_dir = os.path.join(home_dot_repo, 'gnupg')
extra_args = [] extra_args = []
......
...@@ -1040,10 +1040,10 @@ class SVN(object): ...@@ -1040,10 +1040,10 @@ class SVN(object):
auth_dir = os.path.join(os.environ['APPDATA'], 'Subversion', 'auth', auth_dir = os.path.join(os.environ['APPDATA'], 'Subversion', 'auth',
'svn.simple') 'svn.simple')
else: else:
if not 'HOME' in os.environ: auth_dir = os.path.expanduser(
os.path.join('~', '.subversion', 'auth', 'svn.simple'))
if not os.path.exists(auth_dir):
return None return None
auth_dir = os.path.join(os.environ['HOME'], '.subversion', 'auth',
'svn.simple')
for credfile in os.listdir(auth_dir): for credfile in os.listdir(auth_dir):
cred_info = SVN.ReadSimpleAuth(os.path.join(auth_dir, credfile)) cred_info = SVN.ReadSimpleAuth(os.path.join(auth_dir, credfile))
if regexp.match(cred_info.get('svn:realmstring')): if regexp.match(cred_info.get('svn:realmstring')):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment