Commit f202a250 authored by szager@chromium.org's avatar szager@chromium.org

Provide diagnostic messages about netrc failures.

BUG=376546
R=mmoss@chromium.org,agable@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@273002 0039d316-1c4b-4281-b951-d872f2087c98
parent 2c391af0
......@@ -15,14 +15,33 @@ import logging
import netrc
import os
import re
import stat
import sys
import time
import urllib
from cStringIO import StringIO
_netrc_file = '_netrc' if sys.platform.startswith('win') else '.netrc'
_netrc_file = os.path.join(os.environ['HOME'], _netrc_file)
try:
NETRC = netrc.netrc()
except (IOError, netrc.NetrcParseError):
NETRC = netrc.netrc(_netrc_file)
except IOError:
print >> sys.stderr, 'WARNING: Could not read netrc file %s' % _netrc_file
NETRC = netrc.netrc(os.devnull)
except netrc.NetrcParseError as e:
_netrc_stat = os.stat(e.filename)
if _netrc_stat.st_mode & (stat.S_IRWXG | stat.S_IRWXO):
print >> sys.stderr, (
'WARNING: netrc file %s cannot be used because its file permissions '
'are insecure. netrc file permissions should be 600.' % _netrc_file)
else:
print >> sys.stderr, ('ERROR: Cannot use netrc file %s due to a parsing '
'error.' % _netrc_file)
raise
del _netrc_stat
NETRC = netrc.netrc(os.devnull)
del _netrc_file
LOGGER = logging.getLogger()
TRY_LIMIT = 5
......
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