#! /usr/bin/env python

import logging
import os
import platform

from lab.calls.call import Call
from lab import tools

tools.configure_logging()

logging.info(f"node: {platform.node()}")

run_log = open("run.log", "wb")
run_err = open("run.err", "wb", buffering=0)  # disable buffering
redirects = {"stdout": run_log, "stderr": run_err}

# Make sure we're in the run directory.
os.chdir(os.path.dirname(os.path.abspath(__file__)))

Call(['../../width.py', 'mixed-f56-p28-u0-v0-g0-a0-n0-a0-b0-n0-f0-r0_(served_p25).pddl', '--domain', 'domain.pddl', '--benchmark'], hard_stderr_limit=10240, hard_stdout_limit=10240, memory_limit=3584, name='width_computation', soft_stderr_limit=64, soft_stdout_limit=1024, time_limit=1800, wall_time_limit=None, **redirects).wait()


for f in [run_log, run_err]:
    f.close()
    if os.path.getsize(f.name) == 0:
        os.remove(f.name)
