check_return_value.py 490 B

12345678910111213141516171819
  1. #!/usr/bin/env python
  2. # Copyright 2014 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """This program wraps an arbitrary command and prints "1" if the command ran
  6. successfully."""
  7. from __future__ import print_function
  8. import os
  9. import subprocess
  10. import sys
  11. devnull = open(os.devnull, 'wb')
  12. if not subprocess.call(sys.argv[1:], stdout=devnull, stderr=devnull):
  13. print(1)
  14. else:
  15. print(0)