예제 #1
0
파일: views.py 프로젝트: vignanl/Plinth
def warn_about_low_disk_space(request):
    """Warn about insufficient space on root partition."""
    if not is_user_admin(request, cached=True):
        return

    disks = disks_module.get_disks()
    list_root = [disk for disk in disks if disk['mountpoint'] == '/']
    if not list_root:
        logger.error('Error getting information about root partition.')
        return

    perc_used = list_root[0]['percentage_used']
    size_bytes = _interpret_size_string(list_root[0]['size'])
    free_bytes = size_bytes * (100 - perc_used) / 100

    message = format_lazy(_(
        'Warning: Low space on system partition ({percent_used}% used, '
        '{free_space} free).'),
                          percent_used=perc_used,
                          free_space=_format_bytes(free_bytes))

    free_gib = free_bytes / (1024**3)
    if perc_used > 90 or free_gib < 1:
        messages.error(request, message)
    elif perc_used > 75 or free_gib < 2:
        messages.warning(request, message)
예제 #2
0
파일: views.py 프로젝트: fonfon/Plinth
def index(request):
    """Show connection list."""
    disks = disks_module.get_disks()
    root_device = disks_module.get_root_device(disks)
    expandable_root_size = disks_module.is_expandable(root_device)
    expandable_root_size = _format_bytes(expandable_root_size)

    return TemplateResponse(request, 'disks.html',
                            {'title': _('Disks'),
                             'disks': disks,
                             'expandable_root_size': expandable_root_size})
예제 #3
0
파일: views.py 프로젝트: mabkenar/Plinth
def index(request):
    """Show connection list."""
    disks = disks_module.get_disks()
    root_device = disks_module.get_root_device(disks)
    expandable_root_size = disks_module.is_expandable(root_device)
    expandable_root_size = _format_bytes(expandable_root_size)

    return TemplateResponse(
        request, 'disks.html', {
            'title': _('Disks'),
            'disks': disks,
            'expandable_root_size': expandable_root_size
        })
예제 #4
0
파일: views.py 프로젝트: fonfon/Plinth
def expand(request):
    """Warn and expand the root partition."""
    disks = disks_module.get_disks()
    root_device = disks_module.get_root_device(disks)

    if request.method == 'POST':
        expand_partition(request, root_device)
        return redirect(reverse('disks:index'))

    expandable_root_size = disks_module.is_expandable(root_device)
    expandable_root_size = _format_bytes(expandable_root_size)
    return TemplateResponse(request, 'disks_expand.html',
                            {'title': _('Expand Root Partition'),
                             'expandable_root_size': expandable_root_size})
예제 #5
0
파일: views.py 프로젝트: vignanl/Plinth
def expand(request):
    """Warn and expand the root partition."""
    disks = disks_module.get_disks()
    root_device = disks_module.get_root_device(disks)

    if request.method == 'POST':
        expand_partition(request, root_device)
        return redirect(reverse('disks:index'))

    expandable_root_size = disks_module.is_expandable(root_device)
    expandable_root_size = _format_bytes(expandable_root_size)
    return TemplateResponse(
        request, 'disks_expand.html', {
            'title': _('Expand Root Partition'),
            'expandable_root_size': expandable_root_size
        })