How to use _get_partitions method in lisa

Best Python code snippet using lisa_python

partition.py

Source:partition.py Github

copy

Full Screen

...10 super(WindowsPartitionTable, self).__init__()11 self._disk_device = disk_device12 def _create_partition_table(self, style, alignment_in_bytes=None):13 return self._disk_device._disk_object.create_partition_table(style, alignment_in_bytes)14 def _get_partitions(self):15 return gevent_wrapper.defer(self._disk_device._disk_object.get_partitions)()16 def get_disk_drive(self):17 return self._disk_device18 def create_partition_for_whole_table(self, file_system_object, alignment_in_bytes=None):19 self._disk_device._disk_object.create_first_partition(alignment_in_bytes)20 return self.get_partitions()[0]21class WindowsGUIDPartitionTable(WindowsPartitionTable, partition.GUIDPartitionTable):22 @classmethod23 def create_partition_table(cls, disk_drive, alignment_in_bytes=None):24 obj = cls(disk_drive)25 obj._create_partition_table('gpt', alignment_in_bytes)26 return cls(disk_drive)27 def get_partitions(self):28 return [WindowsGUIDPartition(self, partition) for partition in self._get_partitions()]29class WindowsMBRPartitionTable(WindowsPartitionTable, partition.MBRPartitionTable):30 @classmethod31 def create_partition_table(cls, disk_drive, alignment_in_bytes=None):32 obj = cls(disk_drive)33 obj._create_partition_table('mbr', alignment_in_bytes)34 return cls(disk_drive)35 def get_partitions(self):36 return [WindowsPrimaryPartition(self, partition) for partition in self._get_partitions()[:3]] + \37 [WindowsLogicalPartition(self, partition) for partition in self._get_partitions()[3:]]38class WindowsPartition(object):39 def __init__(self, disk_device, partition_object):40 super(WindowsPartition, self).__init__()41 self._disk_device = disk_device42 self._partition_object = partition_object43 def get_size_in_bytes(self):44 return gevent_wrapper.defer(self._partition_object.get_size_in_bytes)()45 @cached_method46 def _get_volume(self):47 from infi.wioctl.api import WindowsException48 from infi.storagemodel import get_storage_model49 from infi.diskmanagement.disk import Volume50 func = gevent_wrapper.defer(Volume.get_from_disk_and_partition)51 try:...

Full Screen

Full Screen

udisks2.py

Source:udisks2.py Github

copy

Full Screen

...19def unmount(path):20 """Unmount the device given by path.21 :return: ."""22 device = resolve_devices(path)[0]23 partitions = _get_partitions(device)24 if partitions:25 for part in partitions:26 _unmount(part)27 else:28 _unmount(device)29def _mount(device):30 31 # This method contains an annoying work-around:32 # The method sleep up to ten times a second waiting for the device to33 # get mountable. On my machine one second is sufficient. If not an34 # irritating message (I presume form the D-Bus system) is displayed35 # even though the exception has been caught.36 counter = 10 # wait maximal seconds37 while counter:38 time.sleep(1)39 counter -= 140 try:41 obj = system_bus.get_object('org.freedesktop.UDisks2', device)42 iface = dbus.Interface(obj, 'org.freedesktop.UDisks2.Filesystem')43 obj.Mount(dict(), dbus_interface="org.freedesktop.UDisks2.Filesystem")44 except dbus.exceptions.DBusException as exc:45 if exc.get_dbus_name() != 'org.freedesktop.UDisks2.Error.AlreadyMounted':46 raise exc47 counter = 048 except ValueError:49 # Linux needs some time after writing the image to get the system ready 50 # for mounting. D-Bus reacts with a ValueError. We wait a second and try again.51 pass52def mount(path):53 """Mount the device given by path.54 55 :return: mounted path."""56 device = resolve_devices(path)[0]57 partitions = _get_partitions(device)58 if partitions:59 for part in partitions:60 _mount(part)61 else:62 _mount(device)63def _get_uuid(device):64 obj = system_bus.get_object('org.freedesktop.UDisks2', device)65 iface = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')66 result = iface.Get('org.freedesktop.UDisks2.Partition', 'UUID')67 return result68def get_partuuid(path, label):69 device = resolve_devices(path)[0]70 for dev in _get_partitions(device):71 if _get_label(dev) == label:72 return _get_uuid(dev)73 return None74def _get_partitions(device):75 obj = system_bus.get_object('org.freedesktop.UDisks2', device)76 iface = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')77 result = iface.Get('org.freedesktop.UDisks2.PartitionTable', 'Partitions')78 return result79def _get_label(device):80 obj = system_bus.get_object('org.freedesktop.UDisks2', device)81 iface = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')82 result = iface.Get('org.freedesktop.UDisks2.Block', 'IdLabel')83 return result84def _get_mountpoint(device):85 obj = system_bus.get_object('org.freedesktop.UDisks2', device)86 iface = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')87 result = iface.Get('org.freedesktop.UDisks2.Filesystem', 'MountPoints', byte_arrays=True)88 return result[0][:-1].decode('UTF-8')89def find_boot(path):90 device = resolve_devices(path)[0]91 for dev in _get_partitions(device):92 if _get_label(dev) == 'boot':93 return _get_mountpoint(dev)...

Full Screen

Full Screen

update.py

Source:update.py Github

copy

Full Screen

...6"""7from kartothek.core.index import PartitionIndex8from kartothek.core.utils import ensure_store9from kartothek.io_components.write import store_dataset_from_partitions10def _get_partitions(dataset, query_params):11 partitions = []12 for params in query_params:13 partitions += dataset.query(**params)14 return partitions15def update_dataset_from_partitions(16 partition_list,17 store_factory,18 dataset_uuid,19 ds_factory,20 delete_scope,21 metadata,22 metadata_merger,23):24 store = ensure_store(store_factory)25 if ds_factory:26 ds_factory = ds_factory.load_all_indices()27 remove_partitions = _get_partitions(ds_factory, delete_scope)28 index_columns = list(ds_factory.indices.keys())29 for column in index_columns:30 index = ds_factory.indices[column]31 if isinstance(index, PartitionIndex):32 del ds_factory.indices[column]33 else:34 # Dataset does not exist yet.35 remove_partitions = []36 new_dataset = store_dataset_from_partitions(37 partition_list=partition_list,38 store=store,39 dataset_uuid=dataset_uuid,40 dataset_metadata=metadata,41 metadata_merger=metadata_merger,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful