def findRepositoriesOnMedia(drivers=False): """ Returns a list of repositories available on local media. """ static_device_patterns = ['sd*', 'scd*', 'sr*', 'xvd*', 'nvme*n*'] static_devices = [] for pattern in static_device_patterns: static_devices.extend( map(os.path.basename, glob.glob('/sys/block/' + pattern))) removable_devices = diskutil.getRemovableDeviceList() removable_devices = filter(lambda x: not x.startswith('fd'), removable_devices) parent_devices = [] partitions = [] for dev in removable_devices + static_devices: if os.path.exists("/dev/%s" % dev): if os.path.exists("/sys/block/%s" % dev): dev_partitions = diskutil.partitionsOnDisk(dev) if len(dev_partitions) > 0: partitions.extend( [x for x in dev_partitions if x not in partitions]) else: if dev not in parent_devices: parent_devices.append(dev) else: if dev not in parent_devices: parent_devices.append(dev) da = None repos = [] try: for check in parent_devices + partitions: device_path = "/dev/%s" % check xelogging.log("Looking for repositories: %s" % device_path) if os.path.exists(device_path): da = DeviceAccessor(device_path) try: da.start() except util.MountFailureException: da = None continue else: if drivers: repo = da.findDriverRepository() else: repo = da.findRepository() if repo: repos.append(repo) da.finish() da = None finally: if da: da.finish() return repos
def get_local_dest(answers): partitions = diskutil.partitionsOnDisk(answers['dest-disk']) if len(partitions) == 0: answers['dest-address'] = answers['dest-disk'] elif len(partitions) == 1: answers['dest-address'] = '/dev/' + partitions[0] else: entries = [] for part in partitions: e = (part, '/dev/' + part) entries.append(e) # default value: default = None if 'dest-address' in answers: default = selectDefault(answers['dest-address'], entries) tui.update_help_line([None, "<F5> more info"]) scroll, height = snackutil.scrollHeight(4, len(entries)) (button, entry) = snackutil.ListboxChoiceWindowEx( tui.screen, "Select Device", "Please select the partition to store the report on.", entries, ['Ok', 'Back'], 55, scroll, height, default, help='getlocaldest:info', hotkeys={'F5': disk_more_info}) tui.screen.popHelpLine() if button == 'back': return uicontroller.LEFT_BACKWARDS # entry contains the 'de' part of the tuple passed in answers['dest-address'] = entry return uicontroller.RIGHT_FORWARDS
def get_local_dest(answers): partitions = diskutil.partitionsOnDisk(answers['dest-disk']) if len(partitions) == 0: answers['dest-address'] = answers['dest-disk'] elif len(partitions) == 1: answers['dest-address'] = '/dev/' + partitions[0] else: entries = [] for part in partitions: e = (part, '/dev/' + part) entries.append(e) # default value: default = None if 'dest-address' in answers: default = selectDefault(answers['dest-address'], entries) tui.update_help_line([None, "<F5> more info"]) scroll, height = snackutil.scrollHeight(4, len(entries)) (button, entry) = snackutil.ListboxChoiceWindowEx( tui.screen, "Select Device", "Please select the partition to store the report on.", entries, ['Ok', 'Back'], 55, scroll, height, default, help = 'getlocaldest:info', hotkey = 'F5', hotkey_cb = disk_more_info) tui.screen.popHelpLine() if button == 'back': return uicontroller.LEFT_BACKWARDS # entry contains the 'de' part of the tuple passed in answers['dest-address'] = entry return uicontroller.RIGHT_FORWARDS