INNER CODE UNIT · Python

run_cli

usepr/eva · showcase/wechat-bot/bot.py:5

def run_cli(args, timeout: int = 300):
    try:
        result = subprocess.run(
            args,
            capture_output=True,
            text=True,
            encoding='utf-8',
            errors='replace',
            cwd=os.getcwd(),
            timeout=timeout,
            shell=False
        )
        output = f"{result.stdout}"
        if result.stderr:
            output += f"\nSTDERR:\n{result.stderr}"
        return output.strip() or "(no output)"
    except Exception as e:
        return f"执行失败:{str(e)}"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…