fix: AppleScript 행별 -e 분할 실행 — 파일 방식 인코딩 문제 회피
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -94,20 +94,18 @@ def run_applescript(script_path: str, *args) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def run_applescript_inline(script: str) -> str:
|
def run_applescript_inline(script: str) -> str:
|
||||||
"""인라인 AppleScript 실행 — 임시 파일 방식 (특수문자 안전)"""
|
"""인라인 AppleScript 실행 — 행별 -e 분할 방식"""
|
||||||
import tempfile
|
lines = script.strip().split('\n')
|
||||||
tmp = tempfile.NamedTemporaryFile(mode='w', suffix='.applescript', delete=False, encoding='utf-8')
|
cmd = ["osascript"]
|
||||||
|
for line in lines:
|
||||||
|
cmd.extend(["-e", line])
|
||||||
try:
|
try:
|
||||||
tmp.write(script)
|
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
|
||||||
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