diff --git a/apply_issue.py b/apply_issue.py index d79ee7b88c..3d606466e7 100755 --- a/apply_issue.py +++ b/apply_issue.py @@ -28,7 +28,7 @@ def main(): parser.add_option( '-e', '--email', - help='Email address for authenticating with Rietveld') + help='IGNORED: Kept for compatibility.') parser.add_option( '-i', '--issue', type='int', help='Rietveld issue number') parser.add_option( @@ -56,15 +56,16 @@ def main(): if not options.server: parser.error('Require a valid server') - # TODO(rogerta): Remove me, it's ugly. - if options.email == '=': - options.email = '' - - obj = rietveld.Rietveld(options.server, options.email, None) + obj = rietveld.Rietveld(options.server, '', None) + try: + properties = obj.get_issue_properties(options.issue, False) + except rietveld.upload.ClientLoginError: + # Requires login. + obj = rietveld.Rietveld(options.server, None, None) + properties = obj.get_issue_properties(options.issue, False) if not options.patchset: - options.patchset = obj.get_issue_properties( - options.issue, False)['patchsets'][-1] + options.patchset = properties['patchsets'][-1] print('No patchset specified. Using patchset %d' % options.patchset) print('Downloading the patch.') diff --git a/rietveld.py b/rietveld.py index 8f95a5db2f..fd00e93ab0 100644 --- a/rietveld.py +++ b/rietveld.py @@ -46,12 +46,11 @@ class Rietveld(object): get_creds, extra_headers=extra_headers or {}) else: - self.rpc_server = upload.GetRpcServer(url, email) - # If email is given as an empty string, then assume we want to make - # requests that do not need authentication. Bypass authentication by - # setting the flag to True. if email == '': - self.rpc_server.authenticated = True + get_creds = lambda: (email, None) + self.rpc_server = upload.HttpRpcServer(url, get_creds) + else: + self.rpc_server = upload.GetRpcServer(url, email) self._xsrf_token = None self._xsrf_token_time = None diff --git a/third_party/upload.py b/third_party/upload.py index 11849fd67d..581ab4d8c4 100755 --- a/third_party/upload.py +++ b/third_party/upload.py @@ -165,7 +165,6 @@ class ClientLoginError(urllib2.HTTPError): def __init__(self, url, code, msg, headers, args): urllib2.HTTPError.__init__(self, url, code, msg, headers, None) self.args = args - self.reason = args["Error"] self.info = args.get("Info", None)