storage, backups: Minor styling and yapf fixes

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-01-23 12:59:07 -08:00 committed by James Valleroy
parent 9e316baa99
commit 41d9419ddd
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
3 changed files with 15 additions and 12 deletions

View File

@ -157,7 +157,8 @@ class UploadArchiveView(SuccessMessageMixin, FormView):
# - For restoring it's highly advisable to have at least as much
# free disk space as the file size.
context['max_filesize'] = storage.format_bytes(
disk_info["free_bytes"] / 2)
disk_info['free_bytes'] / 2)
return context
def form_valid(self, form):
@ -242,12 +243,13 @@ class RestoreArchiveView(BaseRestoreView):
class DownloadArchiveView(View):
"""View to export and download an archive as stream."""
def get(self, request, uuid, name):
repository = get_repository(uuid)
filename = "%s.tar.gz" % name
response = StreamingHttpResponse(repository.get_zipstream(name),
content_type="application/x-gzip")
response = StreamingHttpResponse(
repository.get_zipstream(name), content_type='application/x-gzip')
response['Content-Disposition'] = 'attachment; filename="%s"' % \
filename
return response
@ -293,8 +295,9 @@ class RemoveRepositoryView(SuccessMessageMixin, TemplateView):
"""Delete the archive."""
repository = SshBorgRepository(uuid, automount=False)
repository.remove_repository()
messages.success(request, _('Repository removed. The remote backup '
'itself was not deleted.'))
messages.success(
request,
_('Repository removed. The remote backup itself was not deleted.'))
return redirect('backups:index')

View File

@ -153,9 +153,9 @@ def get_disk_info(mount_point):
free_bytes = list_root[0]['free']
free_gib = free_bytes / (1024**3)
return {
"percent_used": percent_used,
"free_bytes": free_bytes,
"free_gib": free_gib
'percent_used': percent_used,
'free_bytes': free_bytes,
'free_gib': free_gib
}

View File

@ -105,12 +105,12 @@ def warn_about_low_disk_space(request):
# Translators: xgettext:no-python-format
_('Warning: Low space on system partition ({percent_used}% used, '
'{free_space} free).'),
percent_used=root_info["percent_used"],
free_space=storage.format_bytes(root_info["free_bytes"]))
percent_used=root_info['percent_used'],
free_space=storage.format_bytes(root_info['free_bytes']))
if root_info["percent_used"] > 90 or root_info["free_gib"] < 1:
if root_info['percent_used'] > 90 or root_info['free_gib'] < 1:
messages.error(request, message)
elif root_info["percent_used"] > 75 or root_info["free_gib"] < 2:
elif root_info['percent_used'] > 75 or root_info['free_gib'] < 2:
messages.warning(request, message)