fix: AppleScript를 임시 파일로 실행 — osascript -e 이스케이프 문제 해결
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -94,15 +94,20 @@ def run_applescript(script_path: str, *args) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def run_applescript_inline(script: str) -> str:
|
def run_applescript_inline(script: str) -> str:
|
||||||
"""인라인 AppleScript 실행"""
|
"""인라인 AppleScript 실행 — 임시 파일 방식 (특수문자 안전)"""
|
||||||
cmd = ["osascript", "-e", script]
|
import tempfile
|
||||||
|
tmp = tempfile.NamedTemporaryFile(mode='w', suffix='.applescript', delete=False, encoding='utf-8')
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
|
tmp.write(script)
|
||||||
|
tmp.close()
|
||||||
|
result = subprocess.run(["osascript", tmp.name], capture_output=True, text=True, timeout=120)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise RuntimeError(f"AppleScript 에러: {result.stderr.strip()}")
|
raise RuntimeError(f"AppleScript 에러: {result.stderr.strip()}")
|
||||||
return result.stdout.strip()
|
return result.stdout.strip()
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
raise RuntimeError("AppleScript 타임아웃 (인라인)")
|
raise RuntimeError("AppleScript 타임아웃 (인라인)")
|
||||||
|
finally:
|
||||||
|
os.unlink(tmp.name)
|
||||||
|
|
||||||
|
|
||||||
def llm_generate(prompt: str, model: str = "mlx-community/Qwen3.5-35B-A3B-4bit",
|
def llm_generate(prompt: str, model: str = "mlx-community/Qwen3.5-35B-A3B-4bit",
|
||||||
|
|||||||
Reference in New Issue
Block a user