Skip to content

Commit

Permalink
Remove and clone l10n file repos on data pod startup
Browse files Browse the repository at this point in the history
  • Loading branch information
pmac committed Mar 16, 2021
1 parent f52f2cc commit 65217b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions bin/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def update_upload_database():


def schedule_file_jobs():
call_command('l10n_update --clean')

@scheduled_job('interval', minutes=DB_UPDATE_MINUTES)
def update_locales():
call_command('l10n_update')
Expand Down
19 changes: 15 additions & 4 deletions lib/l10n_utils/management/commands/l10n_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')

0 comments on commit 65217b8

Please sign in to comment.