build: chdir back to working directory after makemessages error (#77628)
gitea/publik-django-templatetags/pipeline/head There was a failure building this commit Details

This commit is contained in:
Frédéric Péters 2023-05-15 17:02:11 +02:00
parent a9d0b2f3f0
commit b458b1ceb1
1 changed files with 6 additions and 4 deletions

View File

@ -58,18 +58,19 @@ class make_translations(Command):
pass
def run(self):
curdir = os.getcwd()
try:
from django.core.management import call_command
for path, dirs, files in os.walk('publik_django_templatetags'):
if 'locale' not in dirs:
continue
curdir = os.getcwd()
os.chdir(os.path.realpath(path))
call_command('makemessages', '-l', 'fr', '--add-location', 'file', '--no-obsolete')
os.chdir(curdir)
except ImportError:
sys.stderr.write('!!! Please install Django >= 2.2 to make translations\n')
finally:
os.chdir(curdir)
class compile_translations(Command):
@ -83,18 +84,19 @@ class compile_translations(Command):
pass
def run(self):
curdir = os.getcwd()
try:
from django.core.management import call_command
for path, dirs, files in os.walk('publik_django_templatetags'):
if 'locale' not in dirs:
continue
curdir = os.getcwd()
os.chdir(os.path.realpath(path))
call_command('compilemessages')
os.chdir(curdir)
except ImportError:
sys.stderr.write('!!! Please install Django >= 2.2 to build translations\n')
finally:
os.chdir(curdir)
class build(_build):