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

Side by Side Diff: git_cl.py

Issue 10825107: Remove the use of urllib for SSL connections (Closed) Base URL: https://git.chromium.org/chromium/tools/depot_tools.git@master
Patch Set: Update to add docstring and fix mode on open() call Created 8 years, 4 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 | « no previous file | tests/git_cl_test.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 # Copyright (C) 2008 Evan Martin <martine@danga.com> 6 # Copyright (C) 2008 Evan Martin <martine@danga.com>
7 7
8 """A git-command for integrating reviews on Rietveld.""" 8 """A git-command for integrating reviews on Rietveld."""
9 9
10 import json 10 import json
11 import logging 11 import logging
12 import optparse 12 import optparse
13 import os 13 import os
14 import re 14 import re
15 import stat 15 import stat
16 import sys 16 import sys
17 import textwrap 17 import textwrap
18 import urlparse 18 import urlparse
19 import urllib
20 import urllib2 19 import urllib2
21 20
22 try: 21 try:
23 import readline # pylint: disable=F0401,W0611 22 import readline # pylint: disable=F0401,W0611
24 except ImportError: 23 except ImportError:
25 pass 24 pass
26 25
27 26
28 from third_party import upload 27 from third_party import upload
29 import breakpad # pylint: disable=W0611 28 import breakpad # pylint: disable=W0611
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 RunGit(['config', 'gerrit.port', keyvals['GERRIT_PORT']]) 748 RunGit(['config', 'gerrit.port', keyvals['GERRIT_PORT']])
750 749
751 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: 750 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals:
752 #should be of the form 751 #should be of the form
753 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof 752 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof
754 #ORIGIN_URL_CONFIG: http://src.chromium.org/git 753 #ORIGIN_URL_CONFIG: http://src.chromium.org/git
755 RunGit(['config', keyvals['PUSH_URL_CONFIG'], 754 RunGit(['config', keyvals['PUSH_URL_CONFIG'],
756 keyvals['ORIGIN_URL_CONFIG']]) 755 keyvals['ORIGIN_URL_CONFIG']])
757 756
758 757
758 def urlretrieve(source, destination):
759 """urllib is broken for SSL connections via a proxy therefore we
760 can't use urllib.urlretrieve()."""
761 with open(destination, 'w') as f:
762 f.write(urllib2.urlopen(source).read())
763
764
759 def DownloadHooks(force): 765 def DownloadHooks(force):
760 """downloads hooks 766 """downloads hooks
761 767
762 Args: 768 Args:
763 force: True to update hooks. False to install hooks if not present. 769 force: True to update hooks. False to install hooks if not present.
764 """ 770 """
765 if not settings.GetIsGerrit(): 771 if not settings.GetIsGerrit():
766 return 772 return
767 server_url = settings.GetDefaultServerUrl() 773 server_url = settings.GetDefaultServerUrl()
768 src = '%s/tools/hooks/commit-msg' % server_url 774 src = '%s/tools/hooks/commit-msg' % server_url
769 dst = os.path.join(settings.GetRoot(), '.git', 'hooks', 'commit-msg') 775 dst = os.path.join(settings.GetRoot(), '.git', 'hooks', 'commit-msg')
770 if not os.access(dst, os.X_OK): 776 if not os.access(dst, os.X_OK):
771 if os.path.exists(dst): 777 if os.path.exists(dst):
772 if not force: 778 if not force:
773 return 779 return
774 os.remove(dst) 780 os.remove(dst)
775 try: 781 try:
776 urllib.urlretrieve(src, dst) 782 urlretrieve(src, dst)
777 os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) 783 os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
778 except Exception: 784 except Exception:
779 if os.path.exists(dst): 785 if os.path.exists(dst):
780 os.remove(dst) 786 os.remove(dst)
781 DieWithError('\nFailed to download hooks from %s' % src) 787 DieWithError('\nFailed to download hooks from %s' % src)
782 788
783 789
784 @usage('[repo root containing codereview.settings]') 790 @usage('[repo root containing codereview.settings]')
785 def CMDconfig(parser, args): 791 def CMDconfig(parser, args):
786 """edit configuration for this tree""" 792 """edit configuration for this tree"""
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 1608 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
1603 1609
1604 # Not a known command. Default to help. 1610 # Not a known command. Default to help.
1605 GenUsage(parser, 'help') 1611 GenUsage(parser, 'help')
1606 return CMDhelp(parser, argv) 1612 return CMDhelp(parser, argv)
1607 1613
1608 1614
1609 if __name__ == '__main__': 1615 if __name__ == '__main__':
1610 fix_encoding.fix_encoding() 1616 fix_encoding.fix_encoding()
1611 sys.exit(main(sys.argv[1:])) 1617 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698