def run_hdiutil_command(self, *args, **kwargs): args = ['hdiutil'] + list(args) try: out = Helpers.run_command(*args, **kwargs) except Exception, e: # Some commands require the disk-image to be mounted/unmounted. If ran when it isn't it returns # saying 'Resource temporarily unavailable' if 'Resource temporarily unavailable' in str(e): self.detach() if self.is_mounted() else self.attach() out = Helpers.run_command(*args, **kwargs)
def diskutil_info(self): UTILITY_NAME = 'diskutil' self.attach() response = Helpers.run_command(UTILITY_NAME, 'info', self.get_mounting_point()) non_empty_lines = [line for line in response.splitlines() if line != ''] return {line.split(':')[0].lstrip() : line.split(':')[-1].strip() for line in non_empty_lines}
def change_volname(old_name, new_name): Helpers.run_command('diskutil', 'rename', old_name, new_name)
def run_disk_util_command(self, *args, **kwargs): out = Helpers.run_command(*args, **kwargs)