зеркало из https://github.com/mozilla/bedrock.git
Remove and clone l10n file repos on data pod startup
This commit is contained in:
Родитель
f52f2ccf1f
Коммит
65217b8d85
|
@ -118,6 +118,8 @@ def schedule_database_jobs():
|
|||
|
||||
|
||||
def schedule_file_jobs():
|
||||
call_command('l10n_update --clean')
|
||||
|
||||
@scheduled_job('interval', minutes=DB_UPDATE_MINUTES)
|
||||
def update_locales():
|
||||
call_command('l10n_update')
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
from io import StringIO
|
||||
from shutil import rmtree
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
|
@ -15,20 +16,30 @@ class Command(BaseCommand):
|
|||
def add_arguments(self, parser):
|
||||
parser.add_argument('-q', '--quiet', action='store_true', dest='quiet', default=False,
|
||||
help='If no error occurs, swallow all output.'),
|
||||
parser.add_argument('-c', '--clean', action='store_true', dest='clean', default=False,
|
||||
help='Remove old repos if they exist and do fresh clones.'),
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if options['quiet']:
|
||||
self.stdout._out = StringIO()
|
||||
|
||||
self.update_lang_files()
|
||||
self.update_fluent_files()
|
||||
self.update_lang_files(options['clean'])
|
||||
self.update_fluent_files(options['clean'])
|
||||
|
||||
def update_lang_files(self):
|
||||
def update_lang_files(self, clean=False):
|
||||
repo = GitRepo(settings.LOCALES_PATH, settings.LOCALES_REPO)
|
||||
if clean:
|
||||
rmtree(repo.path_str, ignore_errors=True)
|
||||
self.stdout.write('Removed old .lang repo')
|
||||
|
||||
repo.update()
|
||||
self.stdout.write('Updated .lang files')
|
||||
|
||||
def update_fluent_files(self):
|
||||
def update_fluent_files(self, clean=False):
|
||||
repo = GitRepo(settings.FLUENT_REPO_PATH, settings.FLUENT_REPO_URL)
|
||||
if clean:
|
||||
rmtree(repo.path_str, ignore_errors=True)
|
||||
self.stdout.write('Removed old .ftl repo')
|
||||
|
||||
repo.update()
|
||||
self.stdout.write('Updated .ftl files')
|
||||
|
|
Загрузка…
Ссылка в новой задаче