| 25 | exit(1) |
| 26 | |
| 27 | def mount_dmg(self, dmg, no_browse = False): |
| 28 | # Mounts the passed dmg and returns the mount point(s) |
| 29 | args = ["/usr/bin/hdiutil", "attach", dmg, "-plist", "-noverify"] |
| 30 | if no_browse: |
| 31 | args.append("-nobrowse") |
| 32 | out = self.r.run({"args":args}) |
| 33 | if out[2] != 0: |
| 34 | # Failed! |
| 35 | raise Exception("Mount Failed!", "{} failed to mount:\n\n{}".format(os.path.basename(dmg), out[1])) |
| 36 | # Get the plist data returned, and locate the mount points |
| 37 | try: |
| 38 | plist_data = plist.loads(out[0]) |
| 39 | mounts = [x["mount-point"] for x in plist_data.get("system-entities", []) if "mount-point" in x] |
| 40 | return mounts |
| 41 | except: |
| 42 | raise Exception("Mount Failed!", "No mount points returned from {}".format(os.path.basename(dmg))) |
| 43 | |
| 44 | def unmount_dmg(self, mount_point): |
| 45 | # Unmounts the passed dmg or mount point - retries with force if failed |