1 2 3 4 5 6
def get_output(command, expected_exit=[], *args, **kwargs): try: subprocess.check_output(command, *args, **kwargs) except subprocess.CalledProcessError as e: if e.returncode not in expected_exit: raise