
import os
try:
    import pip
except ImportError:
    pass
import socket


def get_environment():
    """Obtain information about the executing environment.

    Captures:
        * installed Python packages using pip (if available),
        * hostname
        * uname
        * environment variables

    Returns:
        dict: a dict with the keys ``python_packages``, ``hostname``, ``uname`` and ``environ``
    """

    env = {}
    try:
        env['python_packages'] = [str(p) for p in pip.get_installed_distributions()]
    except:
        pass
    env['hostname'] = socket.gethostname()
    env['uname'] = os.uname()
    env['environ'] = dict(os.environ)
    return env


import os
try:
    import pip
except ImportError:
    pass
import socket


def get_environment():
    """Obtain information about the executing environment.

    Captures:
        * installed Python packages using pip (if available),
        * hostname
        * uname
        * environment variables

    Returns:
        dict: a dict with the keys ``python_packages``, ``hostname``, ``uname`` and ``environ``
    """

    env = {}
    try:
        env['python_packages'] = [str(p) for p in pip.get_installed_distributions()]
    except:  # pylint: disable=bare-except
        pass
    env['hostname'] = socket.gethostname()
    env['uname'] = os.uname()
    env['environ'] = dict(os.environ)
    return env

Stop pylint complaining about bare-except
Stop pylint complaining about bare-except

  
  import os
  try:
      import pip
  except ImportError:
      pass
  import socket
  
  
  def get_environment():
      """Obtain information about the executing environment.
  
      Captures:
          * installed Python packages using pip (if available),
          * hostname
          * uname
          * environment variables
  
      Returns:
          dict: a dict with the keys ``python_packages``, ``hostname``, ``uname`` and ``environ``
      """
  
      env = {}
      try:
          env['python_packages'] = [str(p) for p in pip.get_installed_distributions()]
-     except:
+     except:  # pylint: disable=bare-except
          pass
      env['hostname'] = socket.gethostname()
      env['uname'] = os.uname()
      env['environ'] = dict(os.environ)
      return env
  
Stop pylint complaining about bare-except
## Code Before:

import os
try:
    import pip
except ImportError:
    pass
import socket


def get_environment():
    """Obtain information about the executing environment.

    Captures:
        * installed Python packages using pip (if available),
        * hostname
        * uname
        * environment variables

    Returns:
        dict: a dict with the keys ``python_packages``, ``hostname``, ``uname`` and ``environ``
    """

    env = {}
    try:
        env['python_packages'] = [str(p) for p in pip.get_installed_distributions()]
    except:
        pass
    env['hostname'] = socket.gethostname()
    env['uname'] = os.uname()
    env['environ'] = dict(os.environ)
    return env

## Instruction:
Stop pylint complaining about bare-except
## Code After:

import os
try:
    import pip
except ImportError:
    pass
import socket


def get_environment():
    """Obtain information about the executing environment.

    Captures:
        * installed Python packages using pip (if available),
        * hostname
        * uname
        * environment variables

    Returns:
        dict: a dict with the keys ``python_packages``, ``hostname``, ``uname`` and ``environ``
    """

    env = {}
    try:
        env['python_packages'] = [str(p) for p in pip.get_installed_distributions()]
    except:  # pylint: disable=bare-except
        pass
    env['hostname'] = socket.gethostname()
    env['uname'] = os.uname()
    env['environ'] = dict(os.environ)
    return env
