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

Unified Diff: mojo/services/network/upload_network_service.py

Issue 689153007: Script to upload prebuilt network service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « mojo/services/network/udp_socket_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/network/upload_network_service.py
diff --git a/mojo/services/network/upload_network_service.py b/mojo/services/network/upload_network_service.py
new file mode 100755
index 0000000000000000000000000000000000000000..5def62915693c0fbb208b6219c898fd9d1b65150
--- /dev/null
+++ b/mojo/services/network/upload_network_service.py
@@ -0,0 +1,73 @@
+#!/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 os
+import subprocess
+import sys
+import tempfile
+import time
+import zipfile
+
+
+root_path = os.path.realpath(
eseidel 2014/11/05 00:04:26 ALL_CAPS for contstants last I knew: http://legacy
+ os.path.join(
+ os.path.dirname(
+ os.path.realpath(__file__)),
+ os.pardir,
+ os.pardir,
+ os.pardir))
+version = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=root_path)
eseidel 2014/11/05 00:04:26 We will eventually write a mojopy library to do th
+version = version.strip()
+
+if not sys.platform.startswith("linux"):
+ print "Only support linux for now"
+ sys.exit(1)
+
+platform = "linux-x64" # TODO: Parameterize
+binary_dest = "gs://mojo/network/" + version + "/" + platform + ".zip"
+
+sys.path.insert(0, os.path.join(root_path, "tools"))
eseidel 2014/11/05 00:04:27 Are you sure you want to do this?
+import find_depot_tools # pylint: disable=W0611
+
+depot_tools_path = find_depot_tools.add_depot_tools_to_path()
+gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
eseidel 2014/11/05 00:04:27 There is no gsutil helper library for this kind of
+
+
+def gsutil_cp(source, dest, dry_run):
+ if dry_run:
+ print "gsutil cp %s %s" % (source, dest)
+ else:
+ subprocess.check_call([gsutil_exe, "cp", source, dest])
+
+
+def upload_binary(binary_path, dry_run):
+ absolute_binary_path = os.path.join(root_path, binary_path)
+ with tempfile.NamedTemporaryFile() as binary_zip_file:
+ with zipfile.ZipFile(binary_zip_file, 'w') as z:
+ with open(absolute_binary_path) as service_binary:
+ zipinfo = zipfile.ZipInfo("libnetwork_service.so")
+ zipinfo.external_attr = 0o777 << 16
+ zipinfo.compress_type = zipfile.ZIP_DEFLATED
+ zipinfo.date_time = time.gmtime(os.path.getmtime(absolute_binary_path))
+ z.writestr(zipinfo, service_binary.read())
+ gsutil_cp(binary_zip_file.name, binary_dest, dry_run)
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description="Upload network service binary to Google storage")
+ parser.add_argument("-n", "--dry-run", action="store_true", help="Dry run")
+ parser.add_argument(
+ "binary_path",
+ help="Path to network service binary relative to the repo root, e.g. " +
+ "out/Release/libnetwork_service.so")
+ args = parser.parse_args()
+ upload_binary(args.binary_path, args.dry_run)
+ print "Uploaded artifacts for %s %s" % (version, "linux-x64")
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « mojo/services/network/udp_socket_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698