def get_disk_usage(): disk_usage = [] paths = [] for fs_path, percentfull in FileServer.objects.order_by('pk').values_list('filesPrefix', 'percentfull'): if os.path.exists(fs_path): disk_usage.append((fs_path, percentfull)) paths.append(fs_path) mounted = is_mounted(os.path.realpath(fs_path)) if mounted: paths.append(mounted) archive_folders = devices.to_media(devices.disk_report()) for bdir, name in archive_folders: mounted = is_mounted(bdir) if mounted and bdir not in paths: disk_usage.append((bdir, get_disk_attributes_gb(bdir).get('percentfull'))) paths.append(bdir) return disk_usage
def get_disk_usage(): disk_usage = [] paths = [] for fs_path, percentfull in FileServer.objects.order_by("pk").values_list( "filesPrefix", "percentfull"): if os.path.exists(fs_path): disk_usage.append((fs_path, percentfull)) paths.append(fs_path) mounted = is_mounted(os.path.realpath(fs_path)) if mounted: paths.append(mounted) archive_folders = devices.to_media(devices.disk_report()) for bdir, name in archive_folders: mounted = is_mounted(bdir) if mounted and bdir not in paths: disk_usage.append( (bdir, get_disk_attributes_gb(bdir).get("percentfull"))) paths.append(bdir) return disk_usage
def get_dir_choices(): basicChoice = [(None, 'None')] for choice in devices.to_media(devices.disk_report()): basicChoice.append(choice) return tuple(basicChoice)