from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()

import os
import subprocess


def is_return_code_zero(args):
    """Return true iff the given command's return code is zero.

    All the messages to stdout or stderr are suppressed.
    """
    FNULL = open(os.devnull, 'w')
    try:
        subprocess.check_call(args, stdout=FNULL, stderr=FNULL)
    except subprocess.CalledProcessError:
        # The given command returned an error
        return False
    except OSError:
        # The given command was not found
        return False
    return True

from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()

import os
import subprocess


def is_return_code_zero(args):
    """Return true iff the given command's return code is zero.

    All the messages to stdout or stderr are suppressed.
    """
    with open(os.devnull, 'wb') as FNULL:
        try:
            subprocess.check_call(args, stdout=FNULL, stderr=FNULL)
        except subprocess.CalledProcessError:
            # The given command returned an error
            return False
        except OSError:
            # The given command was not found
            return False
        return True

Fix ResourceWarning: unclosed file of devnull
Fix ResourceWarning: unclosed file of devnull

  from __future__ import unicode_literals
  from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  from future import standard_library
  standard_library.install_aliases()
  
  import os
  import subprocess
  
  
  def is_return_code_zero(args):
      """Return true iff the given command's return code is zero.
  
      All the messages to stdout or stderr are suppressed.
      """
-     FNULL = open(os.devnull, 'w')
+     with open(os.devnull, 'wb') as FNULL:
-     try:
+         try:
-         subprocess.check_call(args, stdout=FNULL, stderr=FNULL)
+             subprocess.check_call(args, stdout=FNULL, stderr=FNULL)
-     except subprocess.CalledProcessError:
+         except subprocess.CalledProcessError:
-         # The given command returned an error
+             # The given command returned an error
-         return False
+             return False
-     except OSError:
+         except OSError:
-         # The given command was not found
+             # The given command was not found
-         return False
+             return False
-     return True
+         return True
  
Fix ResourceWarning: unclosed file of devnull
## Code Before:
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()

import os
import subprocess


def is_return_code_zero(args):
    """Return true iff the given command's return code is zero.

    All the messages to stdout or stderr are suppressed.
    """
    FNULL = open(os.devnull, 'w')
    try:
        subprocess.check_call(args, stdout=FNULL, stderr=FNULL)
    except subprocess.CalledProcessError:
        # The given command returned an error
        return False
    except OSError:
        # The given command was not found
        return False
    return True

## Instruction:
Fix ResourceWarning: unclosed file of devnull
## Code After:
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()

import os
import subprocess


def is_return_code_zero(args):
    """Return true iff the given command's return code is zero.

    All the messages to stdout or stderr are suppressed.
    """
    with open(os.devnull, 'wb') as FNULL:
        try:
            subprocess.check_call(args, stdout=FNULL, stderr=FNULL)
        except subprocess.CalledProcessError:
            # The given command returned an error
            return False
        except OSError:
            # The given command was not found
            return False
        return True
