From c77f736df2d4d17982d14bde5698900e08c63c4f Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Sat, 29 Jun 2019 23:29:56 +0200 Subject: [PATCH] mvn_build: replace inline shell scriptlet with native python code --- java-utils/mvn_build.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/java-utils/mvn_build.py b/java-utils/mvn_build.py index 98479962..720787de 100644 --- a/java-utils/mvn_build.py +++ b/java-utils/mvn_build.py @@ -32,6 +32,8 @@ from __future__ import print_function +import base64 +import gzip import os import optparse import subprocess @@ -188,12 +190,17 @@ def goal_callback(option, opt_str, value, parser): p = subprocess.Popen(" ".join(mvn_args), shell=True, env=os.environ) p.wait() - subprocess.Popen(""" - if [ -f .xmvn-builddep ]; then - echo -----BEGIN MAVEN BUILD DEPENDENCIES----- - gzip -9nc <.xmvn-builddep | base64 - echo -----END MAVEN BUILD DEPENDENCIES----- - fi - """, shell=True, env=os.environ).wait() + builddep_file = ".xmvn-builddep" + if os.path.isfile(builddep_file): + with open(builddep_file, "b") as file: + contents = file.read() + + output = "\n".join([ + "-----BEGIN MAVEN BUILD DEPENDENCIES-----", + base64.b64encode(gzip.compress(contents)).decode(), + "-----END MAVEN BUILD DEPENDENCIES-----", + ]) + + print(output, flush=True) sys.exit(p.returncode)