try:
    print('Ping stdout output on success:\n' + subprocess.check_output([
        'ping', '-c', '2', '-w', '2', '8.8.8.8']))
except subprocess.CalledProcessError as e:
    pass
проверить вывод из CalledProcessError