utils: run: rename error_code_ok to check

The Python 3.6 subprocess.run uses the |check| name.

Bug: None
Test: unittests pass
Change-Id: If67f9b6f1275315a867d112cb89bf3431cff4858
diff --git a/rh/git.py b/rh/git.py
index f4c1687..c052d14 100644
--- a/rh/git.py
+++ b/rh/git.py
@@ -202,5 +202,5 @@
 def is_git_repository(path):
     """Returns True if the path is a valid git repository."""
     cmd = ['git', 'rev-parse', '--resolve-git-dir', os.path.join(path, '.git')]
-    result = rh.utils.run(cmd, capture_output=True, error_code_ok=True)
+    result = rh.utils.run(cmd, capture_output=True, check=False)
     return result.returncode == 0
diff --git a/rh/hooks.py b/rh/hooks.py
index e1b530d..3e0c30b 100644
--- a/rh/hooks.py
+++ b/rh/hooks.py
@@ -191,7 +191,7 @@
     kwargs.setdefault('redirect_stderr', True)
     kwargs.setdefault('combine_stdout_stderr', True)
     kwargs.setdefault('capture_output', True)
-    kwargs.setdefault('error_code_ok', True)
+    kwargs.setdefault('check', False)
     return rh.utils.run(cmd, **kwargs)
 
 
diff --git a/rh/utils.py b/rh/utils.py
index 947debe..ded3e68 100644
--- a/rh/utils.py
+++ b/rh/utils.py
@@ -247,10 +247,10 @@
             if e.errno == errno.EPERM:
                 # Kill returns either 0 (signal delivered), or 1 (signal wasn't
                 # delivered).  This isn't particularly informative, but we still
-                # need that info to decide what to do, thus error_code_ok=True.
+                # need that info to decide what to do, thus check=False.
                 ret = sudo_run(['kill', '-%i' % signum, str(self.pid)],
                                redirect_stdout=True,
-                               redirect_stderr=True, error_code_ok=True)
+                               redirect_stderr=True, check=False)
                 if ret.returncode == 1:
                     # The kill binary doesn't distinguish between permission
                     # denied and the pid is missing.  Denied can only occur
@@ -272,8 +272,8 @@
 # pylint: disable=redefined-builtin,input-builtin
 def run(cmd, redirect_stdout=False, redirect_stderr=False, cwd=None, input=None,
         shell=False, env=None, extra_env=None, combine_stdout_stderr=False,
-        error_code_ok=False, int_timeout=1, kill_timeout=1,
-        capture_output=False, close_fds=True):
+        check=True, int_timeout=1, kill_timeout=1, capture_output=False,
+        close_fds=True):
     """Runs a command.
 
     Args:
@@ -291,9 +291,9 @@
       extra_env: If set, this is added to the environment for the new process.
           This dictionary is not used to clear any entries though.
       combine_stdout_stderr: Combines stdout and stderr streams into stdout.
-      error_code_ok: Does not raise an exception when command returns a non-zero
-          exit code.  Instead, returns the CommandResult object containing the
-          exit code.
+      check: Whether to raise an exception when command returns a non-zero exit
+          code, or return the CommandResult object containing the exit code.
+          Note: will still raise an exception if the cmd file does not exist.
       int_timeout: If we're interrupted, how long (in seconds) should we give
           the invoked process to clean up before we send a SIGTERM.
       kill_timeout: If we're interrupted, how long (in seconds) should we give
@@ -421,7 +421,7 @@
 
         cmd_result.returncode = proc.returncode
 
-        if not error_code_ok and proc.returncode:
+        if check and proc.returncode:
             msg = 'cwd=%s' % cwd
             if extra_env:
                 msg += ', extra env=%s' % extra_env
@@ -430,7 +430,7 @@
         estr = str(e)
         if e.errno == errno.EACCES:
             estr += '; does the program need `chmod a+x`?'
-        if error_code_ok:
+        if not check:
             cmd_result = CommandResult(cmd=cmd, error=estr, returncode=255)
         else:
             raise RunCommandError(estr, CommandResult(cmd=cmd), exception=e)
diff --git a/tools/clang-format.py b/tools/clang-format.py
index af28b9e..ce3b301 100755
--- a/tools/clang-format.py
+++ b/tools/clang-format.py
@@ -102,8 +102,7 @@
 
     if diff_filenames:
         if opts.fix:
-            result = rh.utils.run(['git', 'apply'], input=stdout,
-                                  error_code_ok=True)
+            result = rh.utils.run(['git', 'apply'], input=stdout, check=False)
             if result.returncode:
                 print('Error: Unable to automatically fix things.\n'
                       '  Make sure your checkout is clean first.\n'