Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: gerrit_util.py

Issue 1471973004: Fix some path processing to work better on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: lint Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gcl.py ('k') | repo » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """ 5 """
6 Utilities for requesting information for a gerrit server via https. 6 Utilities for requesting information for a gerrit server via https.
7 7
8 https://gerrit-review.googlesource.com/Documentation/rest-api.html 8 https://gerrit-review.googlesource.com/Documentation/rest-api.html
9 """ 9 """
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 """Authenticator implementation that uses ".netrc" for token. 90 """Authenticator implementation that uses ".netrc" for token.
91 """ 91 """
92 92
93 def __init__(self): 93 def __init__(self):
94 self.netrc = self._get_netrc() 94 self.netrc = self._get_netrc()
95 self.gitcookies = self._get_gitcookies() 95 self.gitcookies = self._get_gitcookies()
96 96
97 @staticmethod 97 @staticmethod
98 def _get_netrc(): 98 def _get_netrc():
99 path = '_netrc' if sys.platform.startswith('win') else '.netrc' 99 path = '_netrc' if sys.platform.startswith('win') else '.netrc'
100 path = os.path.join(os.environ['HOME'], path) 100 path = os.path.expanduser(os.path.join('~', path))
101 try: 101 try:
102 return netrc.netrc(path) 102 return netrc.netrc(path)
103 except IOError: 103 except IOError:
104 print >> sys.stderr, 'WARNING: Could not read netrc file %s' % path 104 print >> sys.stderr, 'WARNING: Could not read netrc file %s' % path
105 return netrc.netrc(os.devnull) 105 return netrc.netrc(os.devnull)
106 except netrc.NetrcParseError as e: 106 except netrc.NetrcParseError as e:
107 st = os.stat(e.path) 107 st = os.stat(e.path)
108 if st.st_mode & (stat.S_IRWXG | stat.S_IRWXO): 108 if st.st_mode & (stat.S_IRWXG | stat.S_IRWXO):
109 print >> sys.stderr, ( 109 print >> sys.stderr, (
110 'WARNING: netrc file %s cannot be used because its file ' 110 'WARNING: netrc file %s cannot be used because its file '
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 username = review.get('email', jmsg.get('name', '')) 605 username = review.get('email', jmsg.get('name', ''))
606 raise GerritError(200, 'Unable to set %s label for user "%s"' 606 raise GerritError(200, 'Unable to set %s label for user "%s"'
607 ' on change %s.' % (label, username, change)) 607 ' on change %s.' % (label, username, change))
608 jmsg = GetChangeCurrentRevision(host, change) 608 jmsg = GetChangeCurrentRevision(host, change)
609 if not jmsg: 609 if not jmsg:
610 raise GerritError( 610 raise GerritError(
611 200, 'Could not get review information for change "%s"' % change) 611 200, 'Could not get review information for change "%s"' % change)
612 elif jmsg[0]['current_revision'] != revision: 612 elif jmsg[0]['current_revision'] != revision:
613 raise GerritError(200, 'While resetting labels on change "%s", ' 613 raise GerritError(200, 'While resetting labels on change "%s", '
614 'a new patchset was uploaded.' % change) 614 'a new patchset was uploaded.' % change)
OLDNEW
« no previous file with comments | « gcl.py ('k') | repo » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698