def set_up_logging_file(): buildpackutil.lazy_remove_file("log/out.log") os.mkfifo("log/out.log") log_ratelimit = os.getenv("LOG_RATELIMIT", None) if log_ratelimit is None: subprocess.Popen([ "sed", "--unbuffered", "s|^[0-9\-]\+\s[0-9:\.]\+\s||", "log/out.log", ]) else: log_filter_thread = LogFilterThread(log_ratelimit) log_filter_thread.daemon = True log_filter_thread.start()
def set_up_logging_file(): buildpackutil.lazy_remove_file('log/out.log') os.mkfifo('log/out.log') log_ratelimit = os.getenv('LOG_RATELIMIT', None) if log_ratelimit is None: subprocess.Popen([ 'sed', '--unbuffered', 's|^[0-9\-]\+\s[0-9:\.]\+\s||', 'log/out.log', ]) else: subprocess.Popen([ './bin/mendix-logfilter', '-r', log_ratelimit, '-f', 'log/out.log' ])
def set_up_logging_file(): buildpackutil.lazy_remove_file("log/out.log") os.mkfifo("log/out.log") log_ratelimit = os.getenv("LOG_RATELIMIT", None) if log_ratelimit is None: subprocess.Popen([ "sed", "--unbuffered", "s|^[0-9\-]\+\s[0-9:\.]\+\s||", "log/out.log", ]) else: subprocess.Popen([ "./bin/mendix-logfilter", "-r", log_ratelimit, "-f", "log/out.log", ])
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))