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

Side by Side Diff: rietveld.py

Issue 10704111: Allow apply_issue.py to make api calls to rietveld that don't require (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Removed default for --email option Created 8 years, 5 months 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 | « apply_issue.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Defines class Rietveld to easily access a rietveld instance. 5 """Defines class Rietveld to easily access a rietveld instance.
6 6
7 Security implications: 7 Security implications:
8 8
9 The following hypothesis are made: 9 The following hypothesis are made:
10 - Rietveld enforces: 10 - Rietveld enforces:
(...skipping 29 matching lines...) Expand all
40 self.email = email 40 self.email = email
41 self.password = password 41 self.password = password
42 if email and password: 42 if email and password:
43 get_creds = lambda: (email, password) 43 get_creds = lambda: (email, password)
44 self.rpc_server = upload.HttpRpcServer( 44 self.rpc_server = upload.HttpRpcServer(
45 self.url, 45 self.url,
46 get_creds, 46 get_creds,
47 extra_headers=extra_headers or {}) 47 extra_headers=extra_headers or {})
48 else: 48 else:
49 self.rpc_server = upload.GetRpcServer(url, email) 49 self.rpc_server = upload.GetRpcServer(url, email)
50 # If email is given as an empty string, then assume we want to make
51 # requests that do not need authentication. Bypass authentication by
52 # setting the flag to True.
53 if email == '':
54 self.rpc_server.authenticated = True
55
50 self._xsrf_token = None 56 self._xsrf_token = None
51 self._xsrf_token_time = None 57 self._xsrf_token_time = None
52 58
53 def xsrf_token(self): 59 def xsrf_token(self):
54 if (not self._xsrf_token_time or 60 if (not self._xsrf_token_time or
55 (time.time() - self._xsrf_token_time) > 30*60): 61 (time.time() - self._xsrf_token_time) > 30*60):
56 self._xsrf_token_time = time.time() 62 self._xsrf_token_time = time.time()
57 self._xsrf_token = self.get( 63 self._xsrf_token = self.get(
58 '/xsrf_token', 64 '/xsrf_token',
59 extra_headers={'X-Requesting-XSRF-Token': '1'}) 65 extra_headers={'X-Requesting-XSRF-Token': '1'})
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if not 'Name or service not known' in e.reason: 342 if not 'Name or service not known' in e.reason:
337 # Usually internal GAE flakiness. 343 # Usually internal GAE flakiness.
338 raise 344 raise
339 # If reaching this line, loop again. Uses a small backoff. 345 # If reaching this line, loop again. Uses a small backoff.
340 time.sleep(1+maxtries*2) 346 time.sleep(1+maxtries*2)
341 finally: 347 finally:
342 upload.ErrorExit = old_error_exit 348 upload.ErrorExit = old_error_exit
343 349
344 # DEPRECATED. 350 # DEPRECATED.
345 Send = get 351 Send = get
OLDNEW
« no previous file with comments | « apply_issue.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698