Allow mounting all volumes per device
This commit is contained in:
parent
8a86edb5bb
commit
b3b821a868
1 changed files with 32 additions and 24 deletions
|
|
@ -153,7 +153,7 @@ def cleanup_transfer(dest_path):
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def find_core_storage_volumes():
|
def find_core_storage_volumes(device_path=None):
|
||||||
"""Try to create block devices for any Apple CoreStorage volumes."""
|
"""Try to create block devices for any Apple CoreStorage volumes."""
|
||||||
corestorage_uuid = '53746f72-6167-11aa-aa11-00306543ecac'
|
corestorage_uuid = '53746f72-6167-11aa-aa11-00306543ecac'
|
||||||
dmsetup_cmd_file = '{TmpDir}/dmsetup_command'.format(**global_vars)
|
dmsetup_cmd_file = '{TmpDir}/dmsetup_command'.format(**global_vars)
|
||||||
|
|
@ -162,6 +162,8 @@ def find_core_storage_volumes():
|
||||||
cmd = [
|
cmd = [
|
||||||
'lsblk', '--json', '--list', '--paths',
|
'lsblk', '--json', '--list', '--paths',
|
||||||
'--output', 'NAME,PARTTYPE']
|
'--output', 'NAME,PARTTYPE']
|
||||||
|
if device_path:
|
||||||
|
cmd.append(device_path)
|
||||||
result = run_program(cmd)
|
result = run_program(cmd)
|
||||||
json_data = json.loads(result.stdout.decode())
|
json_data = json.loads(result.stdout.decode())
|
||||||
devs = json_data.get('blockdevices', [])
|
devs = json_data.get('blockdevices', [])
|
||||||
|
|
@ -248,7 +250,9 @@ def get_mounted_volumes():
|
||||||
mounted_volumes.extend(item.get('children', []))
|
mounted_volumes.extend(item.get('children', []))
|
||||||
return {item['source']: item for item in mounted_volumes}
|
return {item['source']: item for item in mounted_volumes}
|
||||||
|
|
||||||
def mount_volumes(all_devices=True, device_path=None, read_write=False):
|
def mount_volumes(
|
||||||
|
all_devices=True, device_path=None,
|
||||||
|
read_write=False, core_storage=True):
|
||||||
"""Mount all detected filesystems."""
|
"""Mount all detected filesystems."""
|
||||||
report = {}
|
report = {}
|
||||||
cmd = [
|
cmd = [
|
||||||
|
|
@ -257,9 +261,10 @@ def mount_volumes(all_devices=True, device_path=None, read_write=False):
|
||||||
if not all_devices and device_path:
|
if not all_devices and device_path:
|
||||||
# Only mount volumes for specific device
|
# Only mount volumes for specific device
|
||||||
cmd.append(device_path)
|
cmd.append(device_path)
|
||||||
else:
|
|
||||||
# Check for Apple CoreStorage volumes first
|
# Check for Apple CoreStorage volumes first
|
||||||
find_core_storage_volumes()
|
if core_storage:
|
||||||
|
find_core_storage_volumes(device_path)
|
||||||
|
|
||||||
# Get list of block devices
|
# Get list of block devices
|
||||||
result = run_program(cmd)
|
result = run_program(cmd)
|
||||||
|
|
@ -269,7 +274,10 @@ def mount_volumes(all_devices=True, device_path=None, read_write=False):
|
||||||
# Get list of volumes
|
# Get list of volumes
|
||||||
volumes = {}
|
volumes = {}
|
||||||
for dev in devs:
|
for dev in devs:
|
||||||
|
if not dev.get('children', []):
|
||||||
|
volumes.update({dev['name']: dev})
|
||||||
for child in dev.get('children', []):
|
for child in dev.get('children', []):
|
||||||
|
if not child.get('children', []):
|
||||||
volumes.update({child['name']: child})
|
volumes.update({child['name']: child})
|
||||||
for grandchild in child.get('children', []):
|
for grandchild in child.get('children', []):
|
||||||
volumes.update({grandchild['name']: grandchild})
|
volumes.update({grandchild['name']: grandchild})
|
||||||
|
|
@ -416,7 +424,7 @@ def run_fast_copy(items, dest):
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
cmd = [global_vars['Tools']['FastCopy'], *FAST_COPY_ARGS]
|
cmd = [global_vars['Tools']['FastCopy'], *FAST_COPY_ARGS]
|
||||||
cmd.append(r'/logfile={}\FastCopy.log'.format(global_vars['LogDir']))
|
cmd.append(r'/logfile={LogDir}\Tools\FastCopy.log'.format(**global_vars))
|
||||||
cmd.extend(items)
|
cmd.extend(items)
|
||||||
cmd.append('/to={}\\'.format(dest))
|
cmd.append('/to={}\\'.format(dest))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue