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

Unified Diff: bootstrap/ingest_source.py

Issue 381043002: Add a virtualenv-based python bootstrapping service to infra. (Closed) Base URL: https://chromium.googlesource.com/infra/infra@master
Patch Set: Address comments, add warning while building on Ubuntu Created 6 years, 5 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
« no previous file with comments | « bootstrap/get_appengine.py ('k') | bootstrap/util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« no previous file with comments | « bootstrap/get_appengine.py ('k') | bootstrap/util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698