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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: bootstrap/ingest_source.py
diff --git a/bootstrap/ingest_source.py b/bootstrap/ingest_source.py
new file mode 100755
index 0000000000000000000000000000000000000000..97ce12eb0be463da4c5f872f149a021a56a79e59
--- /dev/null
+++ b/bootstrap/ingest_source.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+import hashlib
+import os
+import subprocess
+import sys
+
+BUCKET = 'gs://chrome-python-wheelhouse/sources/'
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('path', nargs='+',
+ help='Location of the archive to upload')
+ o = parser.parse_args()
+
+ for path in o.path:
+ fname = os.path.basename(path)
+
+ with open(path, 'rb') as f:
+ data = f.read()
+
+ sha = hashlib.sha1(data).hexdigest()
+ bits = []
+ for bit in reversed(fname.split('.')):
+ if bit in ('tar', 'gz', 'tgz', 'zip', 'bz2'):
+ bits.insert(0, bit)
+ else:
+ break
+ ext = '.' + '.'.join(bits)
+
+ new_fname = sha + ext
+ cmd = ['gsutil', 'cp', '-', BUCKET + new_fname]
+ proc = subprocess.Popen(cmd, stdin=subprocess.PIPE)
+ out, _ = proc.communicate(data)
+ if proc.returncode != 0:
+ raise subprocess.CalledProcessError(proc.returncode, cmd, out)
+
+ print
+
+ print new_fname
+
+
+if __name__ == '__main__':
+ sys.exit(main())

Powered by Google App Engine
This is Rietveld 408576698