fix: AppleScript 행별 -e 분할 실행 — 파일 방식 인코딩 문제 회피

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-26 14:13:48 +09:00
parent 735c0722f4
commit f13b998bbc

View File

@@ -94,20 +94,18 @@ def run_applescript(script_path: str, *args) -> str:
def run_applescript_inline(script: str) -> str:
"""인라인 AppleScript 실행 — 임시 파일 방식 (특수문자 안전)"""
import tempfile
tmp = tempfile.NamedTemporaryFile(mode='w', suffix='.applescript', delete=False, encoding='utf-8')
"""인라인 AppleScript 실행 — 행별 -e 분할 방식"""
lines = script.strip().split('\n')
cmd = ["osascript"]
for line in lines:
cmd.extend(["-e", line])
try:
tmp.write(script)
tmp.close()
result = subprocess.run(["osascript", tmp.name], capture_output=True, text=True, timeout=120)
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
if result.returncode != 0:
raise RuntimeError(f"AppleScript 에러: {result.stderr.strip()}")
return result.stdout.strip()
except subprocess.TimeoutExpired:
raise RuntimeError("AppleScript 타임아웃 (인라인)")
finally:
os.unlink(tmp.name)
def llm_generate(prompt: str, model: str = "mlx-community/Qwen3.5-35B-A3B-4bit",