def start_mxbuild_server(dot_local_location, mx_version): cache = "/tmp/downloads" # disable caching here, not in compile step mono_location = buildpackutil.ensure_and_get_mono(mx_version, cache) mono_env = buildpackutil._get_env_with_monolib(mono_location) path = os.path.join(os.getcwd(), "runtimes", str(mx_version)) if not os.path.isdir(os.path.join(path, "modeler")): buildpackutil.ensure_mxbuild_in_directory( os.path.join(dot_local_location, "mxbuild"), mx_version, cache) path = os.path.join(dot_local_location, "mxbuild") jvm_location = buildpackutil.ensure_and_get_jvm(mx_version, cache, dot_local_location, package="jdk") subprocess.Popen( [ os.path.join(mono_location, "bin/mono"), "--config", os.path.join(mono_location, "etc/mono/config"), os.path.join(path, "modeler", "mxbuild.exe"), "--serve", "--port=6666", "--java-home=%s" % jvm_location, "--java-exe-path=%s/bin/java" % jvm_location, ], env=mono_env, )
def start_mxbuild_server(dot_local_location, mx_version): cache = '/tmp/downloads' # disable caching here, not in compile step mono_location = buildpackutil.ensure_and_get_mono(mx_version, cache) mono_env = buildpackutil._get_env_with_monolib(mono_location) path = os.path.join(os.getcwd(), 'runtimes', str(mx_version)) if not os.path.isdir(os.path.join(path, 'modeler')): buildpackutil.ensure_mxbuild_in_directory( os.path.join(dot_local_location, 'mxbuild'), mx_version, cache) path = os.path.join(dot_local_location, 'mxbuild') jvm_location = buildpackutil.ensure_and_get_jvm( mx_version, cache, dot_local_location, package='jdk', ) subprocess.Popen([ os.path.join(mono_location, 'bin/mono'), '--config', os.path.join(mono_location, 'etc/mono/config'), os.path.join(path, 'modeler', 'mxbuild.exe'), '--serve', '--port=6666', '--java-home=%s' % jvm_location, '--java-exe-path=%s/bin/java' % jvm_location, ], env=mono_env)
def start_mxbuild_server(dot_local_location, mx_version): cache = '/tmp/downloads' # disable caching here, not in compile step mono_location = buildpackutil.ensure_and_get_mono(mx_version, cache) mono_env = buildpackutil._get_env_with_monolib(mono_location) buildpackutil.ensure_mxbuild_in_directory( os.path.join(dot_local_location, 'mxbuild'), mx_version, cache) jdk_location = buildpackutil.ensure_and_return_java_sdk(mx_version, cache) subprocess.Popen([ os.path.join(mono_location, 'bin/mono'), '--config', os.path.join(mono_location, 'etc/mono/config'), os.path.join(dot_local_location, 'mxbuild', 'modeler/mxbuild.exe'), '--serve', '--port=6666', '--java-home=%s' % jdk_location, '--java-exe-path=%s/bin/java' % jdk_location, ], env=mono_env)
def run_mx_build(): mx_version = get_runtime_version() mono_location = buildpackutil.ensure_and_get_mono(mx_version, CACHE_DIR) logging.debug( "Mono available: {mono_location}".format(mono_location=mono_location) ) mono_env = buildpackutil._get_env_with_monolib(mono_location) mxbuild_location = os.path.join(DOT_LOCAL_LOCATION, "mxbuild") buildpackutil.ensure_mxbuild_in_directory( mxbuild_location, mx_version, CACHE_DIR ) jvm_location = buildpackutil.ensure_and_get_jvm( mx_version, CACHE_DIR, DOT_LOCAL_LOCATION ) buildpackutil.lazy_remove_file(BUILD_ERRORS_JSON) args = [ os.path.join(mono_location, "bin/mono"), "--config", os.path.join(mono_location, "etc/mono/config"), os.path.join(mxbuild_location, "modeler/mxbuild.exe"), "--target=package", "--output=/tmp/model.mda", "--java-home=%s" % jvm_location, "--java-exe-path=%s" % os.path.join(jvm_location, "bin/java"), ] if mx_version >= 6.4 or os.environ.get("FORCE_WRITE_BUILD_ERRORS"): args.append("--write-errors=%s" % BUILD_ERRORS_JSON) logging.debug("Will write build errors to %s" % BUILD_ERRORS_JSON) if os.environ.get("FORCED_MXBUILD_URL"): args.append("--loose-version-check") logging.warning( "Using forced mxbuild version, the model will be converted" ) args.append(get_mpr_file()) try: logging.debug("subprocess call {args}".format(args=args)) subprocess.check_call(args, env=mono_env) except subprocess.CalledProcessError as e: buildstatus_callback(BUILD_ERRORS_JSON) raise e for file_name in os.listdir(BUILD_DIR): path = os.path.join(BUILD_DIR, file_name) if file_name != ".local": if os.path.isdir(path): shutil.rmtree(path) else: os.unlink(path) zf = zipfile.ZipFile("/tmp/model.mda") try: zf.extractall(BUILD_DIR) finally: zf.close() try: with open(os.path.join(BUILD_DIR, ".sourcepush"), "w") as f: f.write("sourcepush") except Exception as e: logging.warning("Could not write source push indicator. %s", str(e))