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

Side by Side Diff: gcl.py

Issue 1075723002: Extract authentication options handling into a separate function. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « commit_queue.py ('k') | git_cherry_pick_upload.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
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 5
6 """\ 6 """\
7 Wrapper script around Rietveld's upload.py that simplifies working with groups 7 Wrapper script around Rietveld's upload.py that simplifies working with groups
8 of files. 8 of files.
9 """ 9 """
10 10
11 import json 11 import json
12 import optparse 12 import optparse
13 import os 13 import os
14 import random 14 import random
15 import re 15 import re
16 import ssl 16 import ssl
17 import string 17 import string
18 import sys 18 import sys
19 import tempfile 19 import tempfile
20 import time 20 import time
21 import urllib2 21 import urllib2
22 22
23 import breakpad # pylint: disable=W0611 23 import breakpad # pylint: disable=W0611
24 24
25 25
26 import auth
26 import fix_encoding 27 import fix_encoding
27 import gclient_utils 28 import gclient_utils
28 import git_cl 29 import git_cl
29 import presubmit_support 30 import presubmit_support
30 import rietveld 31 import rietveld
31 from scm import SVN 32 from scm import SVN
32 import subprocess2 33 import subprocess2
33 from third_party import upload 34 from third_party import upload
34 35
35 __version__ = '1.2.1' 36 __version__ = '1.2.1'
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 gclient_utils.FileWrite(GetChangelistInfoFile(self.name), data) 345 gclient_utils.FileWrite(GetChangelistInfoFile(self.name), data)
345 346
346 def Delete(self): 347 def Delete(self):
347 """Removes the changelist information from disk.""" 348 """Removes the changelist information from disk."""
348 os.remove(GetChangelistInfoFile(self.name)) 349 os.remove(GetChangelistInfoFile(self.name))
349 350
350 def RpcServer(self): 351 def RpcServer(self):
351 if not self._rpc_server: 352 if not self._rpc_server:
352 if not self.rietveld: 353 if not self.rietveld:
353 ErrorExit(CODEREVIEW_SETTINGS_FILE_NOT_FOUND) 354 ErrorExit(CODEREVIEW_SETTINGS_FILE_NOT_FOUND)
354 self._rpc_server = rietveld.CachingRietveld(self.rietveld, None, None) 355 # TODO(vadimsh): glc.py should be deleted soon. Do not bother much about
356 # authentication options and always use defaults.
357 self._rpc_server = rietveld.CachingRietveld(
358 self.rietveld, auth.make_auth_config())
355 return self._rpc_server 359 return self._rpc_server
356 360
357 def CloseIssue(self): 361 def CloseIssue(self):
358 """Closes the Rietveld issue for this changelist.""" 362 """Closes the Rietveld issue for this changelist."""
359 # Newer versions of Rietveld require us to pass an XSRF token to POST, so 363 # Newer versions of Rietveld require us to pass an XSRF token to POST, so
360 # we fetch it from the server. 364 # we fetch it from the server.
361 xsrf_token = self.SendToRietveld( 365 xsrf_token = self.SendToRietveld(
362 '/xsrf_token', 366 '/xsrf_token',
363 extra_headers={'X-Requesting-XSRF-Token': '1'}) 367 extra_headers={'X-Requesting-XSRF-Token': '1'})
364 368
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 for fn in dir(sys.modules[__name__]) if fn.startswith('CMD')])) 1462 for fn in dir(sys.modules[__name__]) if fn.startswith('CMD')]))
1459 return 0 1463 return 0
1460 1464
1461 1465
1462 def main(argv): 1466 def main(argv):
1463 if sys.hexversion < 0x02060000: 1467 if sys.hexversion < 0x02060000:
1464 print >> sys.stderr, ( 1468 print >> sys.stderr, (
1465 '\nYour python version %s is unsupported, please upgrade.\n' % 1469 '\nYour python version %s is unsupported, please upgrade.\n' %
1466 sys.version.split(' ', 1)[0]) 1470 sys.version.split(' ', 1)[0])
1467 return 2 1471 return 2
1472
1473 sys.stderr.write('Warning: gcl is going away soon. Get off subversion!\n')
1474 sys.stderr.write('See http://crbug.com/475321 for more details.\n')
1475
1468 if not argv: 1476 if not argv:
1469 argv = ['help'] 1477 argv = ['help']
1470 command = Command(argv[0]) 1478 command = Command(argv[0])
1471 # Help can be run from anywhere. 1479 # Help can be run from anywhere.
1472 if command == CMDhelp: 1480 if command == CMDhelp:
1473 return command(argv[1:]) 1481 return command(argv[1:])
1474 1482
1475 try: 1483 try:
1476 GetRepositoryRoot() 1484 GetRepositoryRoot()
1477 except (gclient_utils.Error, subprocess2.CalledProcessError): 1485 except (gclient_utils.Error, subprocess2.CalledProcessError):
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 return 1 1517 return 1
1510 1518
1511 1519
1512 if __name__ == "__main__": 1520 if __name__ == "__main__":
1513 fix_encoding.fix_encoding() 1521 fix_encoding.fix_encoding()
1514 try: 1522 try:
1515 sys.exit(main(sys.argv[1:])) 1523 sys.exit(main(sys.argv[1:]))
1516 except KeyboardInterrupt: 1524 except KeyboardInterrupt:
1517 sys.stderr.write('interrupted\n') 1525 sys.stderr.write('interrupted\n')
1518 sys.exit(1) 1526 sys.exit(1)
OLDNEW
« no previous file with comments | « commit_queue.py ('k') | git_cherry_pick_upload.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698