diff --git a/apply_issue.py b/apply_issue.py index 3d606466e7..22018742d4 100755 --- a/apply_issue.py +++ b/apply_issue.py @@ -59,8 +59,11 @@ def main(): obj = rietveld.Rietveld(options.server, '', None) try: properties = obj.get_issue_properties(options.issue, False) - except rietveld.upload.ClientLoginError: - # Requires login. + except rietveld.upload.ClientLoginError, e: + if sys.stdout.closed: + print >> sys.stderr, 'Accessing the issue requires login.' + return 1 + print('Accessing the issue requires login.') obj = rietveld.Rietveld(options.server, None, None) properties = obj.get_issue_properties(options.issue, False) @@ -86,7 +89,7 @@ def main(): elif scm_type == 'git': scm_obj = checkout.GitCheckoutBase(options.root_dir, None, None) elif scm_type == None: - scm_obj = checkout.RawCheckout(options.root_dir, None) + scm_obj = checkout.RawCheckout(options.root_dir, None, None) else: parser.error('Couldn\'t determine the scm') diff --git a/rietveld.py b/rietveld.py index fd00e93ab0..ee8f00a879 100644 --- a/rietveld.py +++ b/rietveld.py @@ -47,8 +47,12 @@ class Rietveld(object): extra_headers=extra_headers or {}) else: if 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. get_creds = lambda: (email, None) self.rpc_server = upload.HttpRpcServer(url, get_creds) + self.rpc_server.authenticated = True else: self.rpc_server = upload.GetRpcServer(url, email) diff --git a/third_party/upload.py b/third_party/upload.py index 581ab4d8c4..abd17c742f 100755 --- a/third_party/upload.py +++ b/third_party/upload.py @@ -165,8 +165,13 @@ 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) + @property + def reason(self): + return self._reason + class AbstractRpcServer(object): """Provides a common interface for a simple RPC server."""