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

Side by Side Diff: bootstrap/ingest_source.py

Issue 1200843003: Added virtualenv for depot_tools (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix on Windows Created 5 years, 6 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
OLDNEW
(Empty)
1 #!/usr/bin/env 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 import argparse
7 import hashlib
8 import os
9 import subprocess
10 import sys
11
12 BUCKET = 'gs://chrome-python-wheelhouse/sources/'
13
14
15 def main():
16 parser = argparse.ArgumentParser()
17 parser.add_argument('path', nargs='+',
18 help='Location of the archive to upload')
19 o = parser.parse_args()
20
21 for path in o.path:
22 fname = os.path.basename(path)
23
24 with open(path, 'rb') as f:
25 data = f.read()
26
27 sha = hashlib.sha1(data).hexdigest()
28 bits = []
29 for bit in reversed(fname.split('.')):
30 if bit in ('tar', 'gz', 'tgz', 'zip', 'bz2'):
31 bits.insert(0, bit)
32 else:
33 break
34 ext = '.' + '.'.join(bits)
35
36 new_fname = sha + ext
37 cmd = ['gsutil', 'cp', '-', BUCKET + new_fname]
38 proc = subprocess.Popen(cmd, stdin=subprocess.PIPE)
39 out, _ = proc.communicate(data)
40 if proc.returncode != 0:
41 raise subprocess.CalledProcessError(proc.returncode, cmd, out)
42
43 print
44
45 print new_fname
46
47
48 if __name__ == '__main__':
49 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698