kopia lustrzana https://github.com/OpenDroneMap/WebODM
commit
80b62bca52
|
@ -9,7 +9,7 @@ from webodm import settings
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
from django.utils.translation import get_language
|
from django.utils.translation import get_language
|
||||||
import requests
|
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')
|
logger = logging.getLogger('app.logger')
|
||||||
|
|
||||||
|
@ -20,6 +20,17 @@ def download_file(url, destination):
|
||||||
for chunk in download_stream.iter_content(4096):
|
for chunk in download_stream.iter_content(4096):
|
||||||
fd.write(chunk)
|
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)
|
@user_passes_test(lambda u: u.is_superuser)
|
||||||
def dev_tools(request, action):
|
def dev_tools(request, action):
|
||||||
if not settings.DEV:
|
if not settings.DEV:
|
||||||
|
@ -43,20 +54,19 @@ def dev_tools(request, action):
|
||||||
zip.extractall(path=tmpPath)
|
zip.extractall(path=tmpPath)
|
||||||
os.unlink(tmpzipPath)
|
os.unlink(tmpzipPath)
|
||||||
|
|
||||||
locale_path = glob.glob(os.path.join(tmpPath, "**", "locale"), recursive=True)
|
locale_paths = glob.glob(os.path.join(tmpPath, "**", "locale"), recursive=True)
|
||||||
if len(locale_path) != 1:
|
if len(locale_paths) == 0:
|
||||||
raise Exception(_("Cannot find locale/ folder in .zip archive"))
|
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")
|
webodm_locale_dir = os.path.join(settings.BASE_DIR, "locale")
|
||||||
|
if os.path.isdir(webodm_locale_dir):
|
||||||
logger.info("Removing %s" % webodm_locale_dir)
|
logger.info("Removing %s" % webodm_locale_dir)
|
||||||
shutil.rmtree(webodm_locale_dir)
|
shutil.rmtree(webodm_locale_dir)
|
||||||
|
|
||||||
logger.info("Moving %s to %s..." % (locale_path, os.path.join(settings.BASE_DIR, "locale")))
|
for locale_path in locale_paths:
|
||||||
shutil.move(locale_path, settings.BASE_DIR)
|
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")
|
logger.info("Running translate.sh extract && translate.sh build safe")
|
||||||
translate_script = os.path.join(settings.BASE_DIR, 'translate.sh')
|
translate_script = os.path.join(settings.BASE_DIR, 'translate.sh')
|
||||||
|
|
3
start.sh
3
start.sh
|
@ -50,6 +50,9 @@ if [ "$1" = "--setup-devenv" ] || [ "$2" = "--setup-devenv" ]; then
|
||||||
echo Setup pip requirements...
|
echo Setup pip requirements...
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
echo Build translations...
|
||||||
|
./translate.sh build safe
|
||||||
|
|
||||||
echo Setup webpack watch...
|
echo Setup webpack watch...
|
||||||
webpack --watch &
|
webpack --watch &
|
||||||
fi
|
fi
|
||||||
|
|
Ładowanie…
Reference in New Issue