v1: executing-plans 模式生成,54 文件 1320 行 Python
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from runners.runner import BuildResult, RunResult
|
||||
|
||||
|
||||
class CobolRunner:
|
||||
def compile(self, src_path: str, dialect: str = "ibm") -> BuildResult:
|
||||
stem = Path(src_path).stem
|
||||
out = str(Path(src_path).parent / stem)
|
||||
p = subprocess.run(
|
||||
["cobc", "-x", f"-std={dialect}-strict", "-o", out, src_path],
|
||||
capture_output=True, text=True, timeout=30)
|
||||
return BuildResult(success=p.returncode == 0,
|
||||
artifact_path=out, log=p.stdout + p.stderr)
|
||||
|
||||
def run(self, binary: str, input_path: str, output_path: str) -> RunResult:
|
||||
with open(input_path, "rb") as f:
|
||||
input_data = f.read()
|
||||
p = subprocess.run([binary], input=input_data, capture_output=True, timeout=30)
|
||||
Path(output_path).write_bytes(p.stdout)
|
||||
return RunResult(success=p.returncode == 0,
|
||||
log=(p.stderr or b"").decode() if p.stderr else "")
|
||||
Reference in New Issue
Block a user