old_contents: # -*- coding: utf-8 -*-
  from __future__ import print_function
  import os, sys
  from acq4.util.Mutex import Mutex
  
  # singleton MMCorePy instance
  _mmc = None
  
  # default location to search for micromanager
  # microManagerPath = 'C:\\Program Files\\Micro-Manager-1.4'
  microManagerPath = 'C:\\Program Files\\Micro-Manager-2.0gamma'
  
  
  def getMMCorePy(path=None):
      """Return a singleton MMCorePy instance that is shared by all devices for accessing micromanager.
      """
      global _mmc
      if _mmc is None:
          try:
              import pymmcore
              _mmc = pymmcore.CMMCore()
              _mmc.setDeviceAdapterSearchPaths([microManagerPath])
          except ImportError:
  
              try:
                  import MMCorePy
              except ImportError:
                  if sys.platform != 'win32':
                      raise
                  # MM does not install itself to standard path. User should take care of this,
                  # but we can make a guess..
                  if path is None:
                      path = microManagerPath
                  sys.path.append(path)
                  os.environ['PATH'] = os.environ['PATH'] + ';' + path
                  try:
                      import MMCorePy
                  finally:
                      sys.path.pop()
  
              _mmc = MMCorePy.CMMCore()
  
      return _mmc
  
new_contents: # -*- coding: utf-8 -*-
  from __future__ import print_function
  import os, sys
  from acq4.util.Mutex import Mutex
  
  # singleton MMCorePy instance
  _mmc = None
  
  # default location to search for micromanager
  # microManagerPath = 'C:\\Program Files\\Micro-Manager-1.4'
  microManagerPath = 'C:\\Program Files\\Micro-Manager-2.0gamma'
  
  
  class MMCWrapper:
      """Wraps MMCorePy to raise more helpfule exceptions
      """
      def __init__(self, mmc):
          self.__mmc = mmc
  
      def __getattr__(self, name):
          attr = getattr(self.__mmc, name)
          if not callable(attr):
              return attr
  
          def fn(*args, **kwds):
              try:
                 return attr(*args, **kwds) 
              except RuntimeError as exc:
                  raise RuntimeError(exc.args[0].getFullMsg() + " (calling mmc.%s)"%name)
          fn.__name__ = name + '_wrapped'
          return fn
  
  
  def getMMCorePy(path=None):
      """Return a singleton MMCorePy instance that is shared by all devices for accessing micromanager.
      """
      global _mmc
      if _mmc is None:
          try:
              import pymmcore
              _mmc = MMCWrapper(pymmcore.CMMCore())
              _mmc.setDeviceAdapterSearchPaths([microManagerPath])
          except ImportError:
  
              try:
                  import MMCorePy
              except ImportError:
                  if sys.platform != 'win32':
                      raise
                  # MM does not install itself to standard path. User should take care of this,
                  # but we can make a guess..
                  if path is None:
                      path = microManagerPath
                  sys.path.append(path)
                  os.environ['PATH'] = os.environ['PATH'] + ';' + path
                  try:
                      import MMCorePy
                  finally:
                      sys.path.pop()
  
              _mmc = MMCorePy.CMMCore()
  
      return _mmc
  
subject: raise more helpful error messages from micromanager