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

Side by Side Diff: utils.py

Issue 759163003: Add infrastructure to download golang and build AppRTC collider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/webrtc/webrtc.DEPS/
Patch Set: Created 6 years 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 | « mercurial-src.tar.gz.sha1 ('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')
Property Changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Utilities for all our deps-management stuff."""
7
8 import hashlib
9 import os
10 import shutil
11 import sys
12 import tarfile
13 import zipfile
14
15
16 def ComputeSHA1(path):
17 if not os.path.exists(path):
18 return 0
19
20 sha1 = hashlib.sha1()
21 file_to_hash = open(path, 'rb')
22 try:
23 sha1.update(file_to_hash.read())
24 finally:
25 file_to_hash.close()
26
27 return sha1.hexdigest()
28
29
30 def DeleteDirNextToGclient(directory):
31 # Sanity check to avoid nuking the wrong dirs.
32 if not os.path.exists('.gclient'):
33 raise Exception('Invoked from wrong dir; invoke from dir with .gclient')
34 print 'Deleting %s in %s...' % (directory, os.getcwd())
35 shutil.rmtree(directory, ignore_errors=True)
36
37
38 def UnpackToWorkingDir(archive_path):
39 extension = os.path.splitext(archive_path)[1]
40 if extension == '.zip':
41 _Unzip(archive_path)
42 else:
43 _Untar(archive_path)
44
45
46 def _Unzip(path):
47 print 'Unzipping %s in %s...' % (path, os.getcwd())
48 zip_file = zipfile.ZipFile(path)
49 try:
50 zip_file.extractall()
51 finally:
52 zip_file.close()
53
54
55 def _Untar(path):
56 print 'Untarring %s in %s...' % (path, os.getcwd())
57 tar_file = tarfile.open(path, 'r:gz')
58 try:
59 tar_file.extractall()
60 finally:
61 tar_file.close()
62
63
64 def GetPlatform():
65 if sys.platform.startswith('win'):
66 return 'win'
67 if sys.platform.startswith('linux'):
68 return 'linux'
69 if sys.platform.startswith('darwin'):
70 return 'mac'
71 raise Exception("Can't run on platform %s." % sys.platform)
72
OLDNEW
« no previous file with comments | « mercurial-src.tar.gz.sha1 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698