def check_alongside_disk_layout(): """ Alongside can only work if user has followed the recommended BIOS-Based Disk-Partition Configurations shown in http://technet.microsoft.com/en-us/library/dd744364(v=ws.10).aspx """ # TODO: Add more scenarios where alongside could work partitions = misc.get_partitions() # logging.debug(partitions) extended = False for partition in partitions: if misc.is_partition_extended(partition): extended = True if extended: return False # We just seek for sda partitions partitions_sda = [] for partition in partitions: if "sda" in partition: partitions_sda.append(partition) # There's no extended partition, so all partitions must be primary if len(partitions_sda) < 4: return True return False
def get_type(part): """ Get filesystem type using blkid """ ret = '' if not misc.is_partition_extended(part): try: cmd = ['blkid', '-o', 'value', '-s', 'TYPE', part] ret = subprocess.check_output(cmd).decode().strip() except subprocess.CalledProcessError as err: logging.warning(err) ret = '' return ret
def get_info(part): """ Get partition info using blkid """ # Do not try to get extended partition info ret = '' if not misc.is_partition_extended(part): try: ret = subprocess.check_output(['blkid', part]).decode().strip() except subprocess.CalledProcessError as err: logging.warning(err) ret = '' partdic = {} for info in ret.split(): if '=' in info: info = info.split('=') partdic[info[0]] = info[1].strip('"') return partdic