from sys import platform
from power.common import *
from power.version import VERSION

__version__ = VERSION


try:
    if platform.startswith('darwin'):
        from power.darwin import PowerManagement
    elif platform.startswith('freebsd'):
        from power.freebsd import PowerManagement
    elif platform.startswith('win32'):
        from power.win32 import PowerManagement
    elif platform.startswith('linux'):
        from power.linux import PowerManagement
    else:
        raise RuntimeError("{platform} is not supported.".format(platform=platform))
except RuntimeError as e:
    import warnings
    warnings.warn("Unable to load PowerManagement for {platform}. No-op PowerManagement class is used: {error}".format(error=str(e), platform=platform))
    from power.common import PowerManagementNoop as PowerManagement

from sys import platform
from power.common import *
from power.version import VERSION

__version__ = VERSION


try:
    if platform.startswith('darwin'):
        from power.darwin import PowerManagement
    elif platform.startswith('freebsd'):
        from power.freebsd import PowerManagement
    elif platform.startswith('win32'):
        from power.win32 import PowerManagement
    elif platform.startswith('linux'):
        from power.linux import PowerManagement
    else:
        raise RuntimeError("{platform} is not supported.".format(platform=platform))
except (RuntimeError, ImportError) as e:
    import warnings
    warnings.warn("Unable to load PowerManagement for {platform}. No-op PowerManagement class is used: {error}".format(error=str(e), platform=platform))
    from power.common import PowerManagementNoop as PowerManagement

Use PowerManagementNoop on import errors
Use PowerManagementNoop on import errors

Platform implementation can fail to import its dependencies.

  from sys import platform
  from power.common import *
  from power.version import VERSION
  
  __version__ = VERSION
  
  
  try:
      if platform.startswith('darwin'):
          from power.darwin import PowerManagement
      elif platform.startswith('freebsd'):
          from power.freebsd import PowerManagement
      elif platform.startswith('win32'):
          from power.win32 import PowerManagement
      elif platform.startswith('linux'):
          from power.linux import PowerManagement
      else:
          raise RuntimeError("{platform} is not supported.".format(platform=platform))
- except RuntimeError as e:
+ except (RuntimeError, ImportError) as e:
      import warnings
      warnings.warn("Unable to load PowerManagement for {platform}. No-op PowerManagement class is used: {error}".format(error=str(e), platform=platform))
      from power.common import PowerManagementNoop as PowerManagement
  
Use PowerManagementNoop on import errors
## Code Before:
from sys import platform
from power.common import *
from power.version import VERSION

__version__ = VERSION


try:
    if platform.startswith('darwin'):
        from power.darwin import PowerManagement
    elif platform.startswith('freebsd'):
        from power.freebsd import PowerManagement
    elif platform.startswith('win32'):
        from power.win32 import PowerManagement
    elif platform.startswith('linux'):
        from power.linux import PowerManagement
    else:
        raise RuntimeError("{platform} is not supported.".format(platform=platform))
except RuntimeError as e:
    import warnings
    warnings.warn("Unable to load PowerManagement for {platform}. No-op PowerManagement class is used: {error}".format(error=str(e), platform=platform))
    from power.common import PowerManagementNoop as PowerManagement

## Instruction:
Use PowerManagementNoop on import errors
## Code After:
from sys import platform
from power.common import *
from power.version import VERSION

__version__ = VERSION


try:
    if platform.startswith('darwin'):
        from power.darwin import PowerManagement
    elif platform.startswith('freebsd'):
        from power.freebsd import PowerManagement
    elif platform.startswith('win32'):
        from power.win32 import PowerManagement
    elif platform.startswith('linux'):
        from power.linux import PowerManagement
    else:
        raise RuntimeError("{platform} is not supported.".format(platform=platform))
except (RuntimeError, ImportError) as e:
    import warnings
    warnings.warn("Unable to load PowerManagement for {platform}. No-op PowerManagement class is used: {error}".format(error=str(e), platform=platform))
    from power.common import PowerManagementNoop as PowerManagement
