Index: mojo/tools/upload_shell_binary.py |
diff --git a/mojo/tools/upload_shell_binary.py b/mojo/tools/upload_shell_binary.py |
index f9c1ff1f697b76ec2f0e58eee97ca46abcc3702f..91c0ed9239fd500ab2ed3d437aa497992710af05 100755 |
--- a/mojo/tools/upload_shell_binary.py |
+++ b/mojo/tools/upload_shell_binary.py |
@@ -11,30 +11,30 @@ import tempfile |
import time |
import zipfile |
-root_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), |
- "..", "..") |
+from mopy.paths import Paths |
+from mopy.version import Version |
-sys.path.insert(0, os.path.join(root_path, "tools")) |
+paths = Paths(os.path.join("out", "Release")) |
+ |
+sys.path.insert(0, os.path.join(paths.src_root, "tools")) |
# pylint: disable=F0401 |
import find_depot_tools |
-binary_path = os.path.join(root_path, "out", "Release", "mojo_shell") |
- |
depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil") |
-def upload(dry_run): |
- version = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=root_path) |
- version = version.strip() |
- dest = "gs://mojo/shell/" + version + "/linux-x64.zip" |
+def upload(dry_run, verbose): |
+ dest = "gs://mojo/shell/" + Version().version + "/linux-x64.zip" |
with tempfile.NamedTemporaryFile() as zip_file: |
with zipfile.ZipFile(zip_file, 'w') as z: |
- with open(binary_path) as shell_binary: |
+ with open(paths.mojo_shell_path) as shell_binary: |
zipinfo = zipfile.ZipInfo("mojo_shell") |
zipinfo.external_attr = 0777 << 16L |
zipinfo.compress_type = zipfile.ZIP_DEFLATED |
- zipinfo.date_time = time.gmtime(os.path.getmtime(binary_path)) |
+ zipinfo.date_time = time.gmtime(os.path.getmtime(paths.mojo_shell_path)) |
+ if verbose: |
+ print "zipping %s" % paths.mojo_shell_path |
z.writestr(zipinfo, shell_binary.read()) |
if dry_run: |
print str([gsutil_exe, "cp", zip_file.name, dest]) |
@@ -46,8 +46,10 @@ def main(): |
"google storage") |
parser.add_argument("-n", "--dry_run", help="Dry run, do not actually "+ |
"upload", action="store_true") |
+ parser.add_argument("-v", "--verbose", help="Verbose mode", |
+ action="store_true") |
args = parser.parse_args() |
- upload(args.dry_run) |
+ upload(args.dry_run, args.verbose) |
return 0 |
if __name__ == "__main__": |