「Pythonで外部プロセスを起動して出力と戻り値を処理する」で以前扱ったPythonのsubprocessモジュールに関する追加のメモとなる。 subprocess.check_call() subprocess.check_call()はsubprocess.Popenオブジェクトのコンストラクタ引数と同じ書式でコマンド行を実行し、正常に終了したら関数も正常終了するが、正常に終了しなかったときにsubprocess.CalledProcessError例外が発生するという便利なもの。 #! /usr/bin/python # -*- coding: utf-8 -*- import subprocess import sys print '-' * 80 # 子プロセスが正常に終了する例 try: subprocess.check_call(['uname', '-a']) excep