def AttachDiskImage(path):
  """attaches a dmg, returns mountpoint, assuming only one filesystem."""

  command = ["/usr/bin/hdiutil", "attach", path, "-mountrandom", "/tmp",
             "-readonly", "-nobrowse", "-noautoopen", "-plist",
             "-owners", "on"]
  task = subprocess.Popen(command,
                          stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE)
  (stdout, stderr) = task.communicate()
  if task.returncode:
    print "There was an error attaching dmg: %s" % path
    print stderr
    return False
  else:
    mountpoint = False
    dmg_plist = plistlib.readPlistFromString(stdout)
    entities = dmg_plist["system-entities"]
    for entity in entities:
      if "mount-point" in entity:
        mountpoint = entity["mount-point"]
    return mountpoint
dataset/ETHPy150Open MacSysadmin/pymacadmin/utilities/diskimage_unittesting/run_image_tests.py/AttachDiskImage/original