Exemplo n.º 1
0
def get_share_mounts():
    """Return list of mount points."""
    ignore_points = ('/boot', '/boot/efi', '/boot/firmware', '/.snapshots')
    return [
        mount for mount in storage.get_mounts()
        if mount['mount_point'] not in ignore_points
    ]
Exemplo n.º 2
0
def get_available_samba_shares():
    """Get available samba shares."""
    available_shares = []
    if is_module_enabled('samba'):
        samba_shares = json.loads(
            actions.superuser_run('samba', ['get-shares']))
        if samba_shares:
            disks = storage.get_mounts()
            for share in samba_shares:
                for disk in disks:
                    if share['mount_point'] == disk['mount_point']:
                        available_shares.append(share)
                        break
    return available_shares
Exemplo n.º 3
0
def get_share_mounts():
    """Return list of shareable mounts."""
    ignore_mounts = ('/boot', '/boot/efi', '/boot/firmware', '/.snapshots')
    mounts = []

    for mount in storage.get_mounts():
        mount_point = mount['mount_point']
        if mount_point not in ignore_mounts:
            basename = os.path.basename(mount_point)
            mount['name'] = basename or _('FreedomBox OS disk')
            mount['share_name_prefix'] = basename or 'disk'
            mounts.append(mount)

    return sorted(mounts, key=lambda k: k['mount_point'])
Exemplo n.º 4
0
def get_disk_choices():
    """Returns a list of all available partitions except the root partition."""
    repositories = get_repositories()
    existing_paths = [
        repository.path for repository in repositories
        if repository.storage_type == 'disk'
    ]
    choices = []
    for device in get_mounts():
        if device['mount_point'] == '/':
            continue

        path = os.path.join(device['mount_point'], 'FreedomBoxBackups')
        if path in existing_paths:
            continue

        name = device['label'] if device['label'] else device['mount_point']
        choices.append((device['mount_point'], name))

    return choices