Files
mayan-edms/mayan/apps/smart_settings/management/commands/revertsettings.py
Roberto Rosario 8e39016f12 Code cleanups.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
2018-08-21 18:57:38 -04:00

28 lines
769 B
Python

from __future__ import unicode_literals
import errno
from shutil import copyfile
from django.conf import settings
from django.core import management
class Command(management.BaseCommand):
help = 'Rollback the configuration file to the last valid version.'
def handle(self, *args, **options):
try:
copyfile(
settings.CONFIGURATION_LAST_GOOD_FILEPATH,
settings.CONFIGURATION_FILEPATH
)
except IOError as exception:
if exception.errno == errno.ENOENT:
self.stdout.write(
self.style.NOTICE(
'There is no last valid version to restore.'
)
)
else:
raise