code: def script(inbox, cfg):
      script_name = cfg["id"]
      script_id = str(abs(hash((cfg["id"],) + tuple(inbox[0].values()))))[0:8]
      args = {}
      args["params"] = dict(cfg["params"])
      args["in"] = {}
      for in_port in cfg["in"]:
          for inin_ports in inbox:
              in_path = inin_ports.get(in_port, None)
              if (in_path is not None):
                  args["in"][in_port] = in_path
                  break
      if len(args["in"]) < len(cfg["in"]):
          raise Exception("not all in_ports connected, got: %s" % (args["in"],))
      args["out"] = {}
      out = {}
      for i, (out_port, out_ext) in enumerate(cfg["out"]):
          if cfg["in"] == tuple(out_port_ for out_port_, _ in cfg["out"]):
              pfx = args["in"][cfg["in"][i]].split("/")[-1].split(".")[0] + "_"
              base = cfg["id"]
          else:
              pfx = args["in"][cfg["in"][0]].split("/")[-1].split(".")[0] + "_"
              base = cfg["id"] + "-" + out_port 
          if out_ext:
              out_path = cfg["dir"] + "/" + pfx + base + "." + out_ext
          else:
              out_path = cfg["dir"] + "/" + pfx + base
          args["out"][out_port] = out_path
          out[out_port] = out_path
      ret = _eval_script(cfg["evaluator"], cfg["preamble"], cfg["dir"], cfg["executable"], cfg["script"], args)
      if ret[0] != 0:
          raise Exception(ret[0], cfg["script"], ret[1], ret[2])
      return out