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

View File

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

View File

@ -105,12 +105,12 @@ def warn_about_low_disk_space(request):
# Translators: xgettext:no-python-format # Translators: xgettext:no-python-format
_('Warning: Low space on system partition ({percent_used}% used, ' _('Warning: Low space on system partition ({percent_used}% used, '
'{free_space} free).'), '{free_space} free).'),
percent_used=root_info["percent_used"], percent_used=root_info['percent_used'],
free_space=storage.format_bytes(root_info["free_bytes"])) 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) 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) messages.warning(request, message)