kopia lustrzana https://github.com/OpenDroneMap/WebODM
Fixed locale reload
rodzic
f97cb7a33f
commit
9fddc37b3b
|
@ -9,7 +9,7 @@ from webodm import settings
|
|||
from django.http import JsonResponse
|
||||
from django.utils.translation import get_language
|
||||
import requests
|
||||
import json, tempfile, os, logging, shutil, subprocess, zipfile, glob
|
||||
import json, tempfile, os, logging, shutil, subprocess, zipfile, glob, pathlib
|
||||
|
||||
logger = logging.getLogger('app.logger')
|
||||
|
||||
|
@ -20,6 +20,17 @@ def download_file(url, destination):
|
|||
for chunk in download_stream.iter_content(4096):
|
||||
fd.write(chunk)
|
||||
|
||||
def copymerge(src, dst, symlinks=False, ignore=None):
|
||||
for item in os.listdir(src):
|
||||
s = os.path.join(src, item)
|
||||
d = os.path.join(dst, item)
|
||||
if os.path.isdir(s):
|
||||
pathlib.Path(d).mkdir(parents=True, exist_ok=True)
|
||||
copymerge(s, d, symlinks, ignore)
|
||||
else:
|
||||
shutil.copy2(s, d)
|
||||
|
||||
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
def dev_tools(request, action):
|
||||
if not settings.DEV:
|
||||
|
@ -43,20 +54,19 @@ def dev_tools(request, action):
|
|||
zip.extractall(path=tmpPath)
|
||||
os.unlink(tmpzipPath)
|
||||
|
||||
locale_path = glob.glob(os.path.join(tmpPath, "**", "locale"), recursive=True)
|
||||
if len(locale_path) != 1:
|
||||
locale_paths = glob.glob(os.path.join(tmpPath, "**", "locale"), recursive=True)
|
||||
if len(locale_paths) == 0:
|
||||
raise Exception(_("Cannot find locale/ folder in .zip archive"))
|
||||
|
||||
locale_path = locale_path[0]
|
||||
logger.info("Found locale at %s" % locale_path)
|
||||
|
||||
webodm_locale_dir = os.path.join(settings.BASE_DIR, "locale")
|
||||
if os.path.isdir(webodm_locale_dir):
|
||||
logger.info("Removing %s" % webodm_locale_dir)
|
||||
shutil.rmtree(webodm_locale_dir)
|
||||
|
||||
logger.info("Removing %s" % webodm_locale_dir)
|
||||
shutil.rmtree(webodm_locale_dir)
|
||||
|
||||
logger.info("Moving %s to %s..." % (locale_path, os.path.join(settings.BASE_DIR, "locale")))
|
||||
shutil.move(locale_path, settings.BASE_DIR)
|
||||
for locale_path in locale_paths:
|
||||
logger.info("Found locale at %s" % locale_path)
|
||||
logger.info("Moving %s to %s..." % (locale_path, webodm_locale_dir))
|
||||
copymerge(locale_path, webodm_locale_dir)
|
||||
|
||||
logger.info("Running translate.sh extract && translate.sh build safe")
|
||||
translate_script = os.path.join(settings.BASE_DIR, 'translate.sh')
|
||||
|
|
Ładowanie…
Reference in New Issue