mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
snapshot: Format code with yapf
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
9bd45927d7
commit
04d5f12ae0
@ -55,7 +55,8 @@ def parse_arguments():
|
||||
subparser = subparsers.add_parser('rollback', help='Rollback to snapshot')
|
||||
subparser.add_argument('number', help='Number of snapshot to rollback to')
|
||||
|
||||
subparser = subparsers.add_parser('disable-apt-snapshot', help='enable/disable apt snapshots')
|
||||
subparser = subparsers.add_parser('disable-apt-snapshot',
|
||||
help='enable/disable apt snapshots')
|
||||
subparser.add_argument('state')
|
||||
|
||||
subparsers.required = True
|
||||
@ -161,10 +162,9 @@ def _get_default_snapshot():
|
||||
|
||||
def subcommand_disable_apt_snapshot(arguments):
|
||||
"""Set flag to Enable/Disable apt software snapshots in config files"""
|
||||
|
||||
"""Initialize Augeas."""
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||
aug.set('/augeas/load/Shellvars/incl[last() + 1]', DEFAULT_FILE)
|
||||
aug.load()
|
||||
|
||||
@ -70,8 +70,8 @@ def setup(helper, old_version=None):
|
||||
|
||||
def load_augeas():
|
||||
"""Initialize Augeas."""
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
|
||||
# shell-script config file lens
|
||||
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||
|
||||
@ -24,16 +24,15 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
class SnapshotForm(forms.Form):
|
||||
enable_timeline_snapshots = forms.ChoiceField(
|
||||
label=_('Timeline Snapshots'),
|
||||
help_text=_('Enable or disable timeline snapshots '
|
||||
'(hourly, daily, monthly and yearly).'),
|
||||
label=_('Timeline Snapshots'), help_text=_(
|
||||
'Enable or disable timeline snapshots '
|
||||
'(hourly, daily, monthly and yearly).'),
|
||||
choices=[('yes', 'Enabled'), ('no', 'Disabled')])
|
||||
|
||||
enable_software_snapshots = forms.ChoiceField(
|
||||
label=_('Software Installation Snapshots'),
|
||||
help_text=_('Enable or disable snapshots before and after software '
|
||||
'installation'),
|
||||
choices=[('yes', 'Enabled'), ('no', 'Disabled')])
|
||||
label=_('Software Installation Snapshots'), help_text=_(
|
||||
'Enable or disable snapshots before and after software '
|
||||
'installation'), choices=[('yes', 'Enabled'), ('no', 'Disabled')])
|
||||
|
||||
hourly_limit = forms.IntegerField(
|
||||
label=_('Hourly Snapshots Limit'), min_value=0,
|
||||
|
||||
@ -55,14 +55,13 @@ def index(request):
|
||||
else:
|
||||
form = SnapshotForm(initial=status)
|
||||
|
||||
return TemplateResponse(
|
||||
request, 'snapshot.html', {
|
||||
'title': snapshot_module.name,
|
||||
'description': snapshot_module.description,
|
||||
'manual_page': snapshot_module.manual_page,
|
||||
'subsubmenu': subsubmenu,
|
||||
'form': form
|
||||
})
|
||||
return TemplateResponse(request, 'snapshot.html', {
|
||||
'title': snapshot_module.name,
|
||||
'description': snapshot_module.description,
|
||||
'manual_page': snapshot_module.manual_page,
|
||||
'subsubmenu': subsubmenu,
|
||||
'form': form
|
||||
})
|
||||
|
||||
|
||||
def manage(request):
|
||||
@ -77,12 +76,11 @@ def manage(request):
|
||||
has_deletable_snapshots = any(
|
||||
[snapshot for snapshot in snapshots[1:] if not snapshot['is_default']])
|
||||
|
||||
return TemplateResponse(
|
||||
request, 'snapshot_manage.html', {
|
||||
'snapshots': snapshots,
|
||||
'has_deletable_snapshots': has_deletable_snapshots,
|
||||
'subsubmenu': subsubmenu,
|
||||
})
|
||||
return TemplateResponse(request, 'snapshot_manage.html', {
|
||||
'snapshots': snapshots,
|
||||
'has_deletable_snapshots': has_deletable_snapshots,
|
||||
'subsubmenu': subsubmenu,
|
||||
})
|
||||
|
||||
|
||||
def update_configuration(request, old_status, new_status):
|
||||
@ -108,7 +106,8 @@ def update_configuration(request, old_status, new_status):
|
||||
('number_min_age', 'NUMBER_MIN_AGE={}'),
|
||||
]))
|
||||
|
||||
if old_status['enable_software_snapshots'] != new_status['enable_software_snapshots']:
|
||||
if old_status['enable_software_snapshots'] != new_status[
|
||||
'enable_software_snapshots']:
|
||||
if new_status['enable_software_snapshots'] == 'yes':
|
||||
actions.superuser_run('snapshot', ['disable-apt-snapshot', 'no'])
|
||||
else:
|
||||
@ -130,8 +129,7 @@ def delete(request, number):
|
||||
if request.method == 'POST':
|
||||
actions.superuser_run('snapshot', ['delete', number])
|
||||
messages.success(
|
||||
request,
|
||||
_('Deleted snapshot #{number}.').format(number=number))
|
||||
request, _('Deleted snapshot #{number}.').format(number=number))
|
||||
return redirect(reverse('snapshot:manage'))
|
||||
|
||||
output = actions.superuser_run('snapshot', ['list'])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user