-
-
Notifications
You must be signed in to change notification settings - Fork 977
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #989 from pierotofy/desktop
Desktop mode
- Loading branch information
Showing
31 changed files
with
405 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os | ||
from django.core.management.base import BaseCommand | ||
from nodeodm.models import ProcessingNode | ||
|
||
class Command(BaseCommand): | ||
requires_system_checks = [] | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument("host", type=str) | ||
parser.add_argument("port", type=int) | ||
parser.add_argument("--label", type=str, required=False, default="", help="Node label") | ||
parser.add_argument("--token", type=str, required=False, default="", help="Node token") | ||
|
||
super(Command, self).add_arguments(parser) | ||
|
||
def handle(self, **options): | ||
ProcessingNode.objects.update_or_create(hostname=options.get('host'), | ||
defaults={ | ||
'hostname': options.get('host'), | ||
'port': options.get('port'), | ||
'label': options.get('label', ''), | ||
'token': options.get('token', '') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
import shutil | ||
import glob | ||
from django.core.management.base import BaseCommand | ||
from app.plugins import build_plugins | ||
|
||
def cleanup(): | ||
# Delete all node_modules and build directories within plugins' public/ folders | ||
root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..")) | ||
for d in glob.glob(os.path.join(root, "plugins", "**", "public", "node_modules")): | ||
shutil.rmtree(d) | ||
print("R\t" + d) | ||
for d in glob.glob(os.path.join(root, "plugins", "**", "public", "build")): | ||
shutil.rmtree(d) | ||
print("R\t" + d) | ||
|
||
print("Cleanup done!") | ||
|
||
class Command(BaseCommand): | ||
requires_system_checks = [] | ||
|
||
def add_arguments(self, parser): | ||
super(Command, self).add_arguments(parser) | ||
|
||
def handle(self, **options): | ||
cleanup() | ||
build_plugins() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import os | ||
from django.core.management.base import BaseCommand | ||
from django.core.management import call_command | ||
|
||
from app.scripts.extract_odm_strings import extract_odm_strings | ||
from app.scripts.extract_plugin_manifest_strings import extract_plugin_manifest_strings | ||
from app.scripts.extract_potree_strings import extract_potree_strings | ||
|
||
root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..")) | ||
|
||
class Command(BaseCommand): | ||
requires_system_checks = [] | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument("action", type=str, choices=['extract', 'build']) | ||
parser.add_argument("--safe", action='store_true', required=False, help="Skip invalid languages") | ||
super(Command, self).add_arguments(parser) | ||
|
||
def handle(self, **options): | ||
with open(os.path.join(root, "LOCALES")) as f: | ||
locales = f.read().strip().split(" ") | ||
|
||
if options.get('action') == 'extract': | ||
print("Extracting .po files from Django/React") | ||
locale_params = ["--locale=%s" % l for l in locales] | ||
|
||
locale_dir = os.path.join(root, "locale") | ||
if not os.path.exists(locale_dir): | ||
os.mkdir(locale_dir) | ||
|
||
extract_potree_strings( | ||
os.path.join(root, "app", "static", "app", "js", "vendor", "potree", "build", "potree", "resources", "lang", "en", "translation.json"), | ||
os.path.join(root, "app", "static", "app", "js", "translations", "potree_autogenerated.js") | ||
) | ||
extract_odm_strings( | ||
"https://raw.githubusercontent.com/OpenDroneMap/ODM/master/opendm/config.py", | ||
os.path.join(root, "app", "static", "app", "js", "translations", "odm_autogenerated.js") | ||
) | ||
extract_plugin_manifest_strings( | ||
os.path.join(root, "plugins"), | ||
os.path.join(root, "app", "translations", "plugin_manifest_autogenerated.py") | ||
) | ||
|
||
call_command('makemessages', '--keep-pot', *locale_params, '--ignore=build', '--ignore=app/templates/app/registration/*') | ||
call_command('makemessages_djangojs', '--keep-pot', *locale_params, '-d=djangojs', '--extension=jsx', '--extension=js', '--ignore=build', '--ignore=app/static/app/js/vendor', '--ignore=app/static/app/bundles', '--ignore=node_modules', '--language=Python') | ||
|
||
elif options.get('action') == 'build': | ||
if options.get('safe'): | ||
for l in locales: | ||
print("Building %s .po files into .mo" % l) | ||
call_command('compilemessages', '--locale=%s' % l) | ||
else: | ||
print("Building .po files into .mo") | ||
call_command('compilemessages') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,37 @@ | ||
#!/usr/bin/python3 | ||
|
||
import argparse, json, os, glob | ||
import json, os, glob | ||
|
||
parser = argparse.ArgumentParser(description='Extract plugin manifest strings.') | ||
parser.add_argument('input', type=str, | ||
help='Path to plugins directory') | ||
parser.add_argument('output', type=str, | ||
help='Where to write resulting translation file') | ||
args = parser.parse_args() | ||
def extract_plugin_manifest_strings(plugins_dir, output): | ||
strings = [] | ||
manifests = glob.glob(os.path.join(plugins_dir, "*", "manifest.json"), recursive=True) | ||
print("Found %s manifests" % len(manifests)) | ||
|
||
strings = [] | ||
manifests = glob.glob(os.path.join(args.input, "*", "manifest.json"), recursive=True) | ||
print("Found %s manifests" % len(manifests)) | ||
for m in manifests: | ||
with open(m) as f: | ||
j = json.loads(f.read()) | ||
if j.get("description"): | ||
strings.append(j.get("description")) | ||
|
||
for m in manifests: | ||
with open(m) as f: | ||
j = json.loads(f.read()) | ||
if j.get("description"): | ||
strings.append(j.get("description")) | ||
print("Found %s manifest strings" % len(strings)) | ||
if len(strings) > 0: | ||
with open(output, "w") as f: | ||
f.write("// Auto-generated with extract_plugin_manifest_strings.py, do not edit!\n\n") | ||
f.write("from django.utils.translation import gettext as _\n") | ||
|
||
for s in strings: | ||
f.write("_(\"%s\")\n" % s.replace("\"", "\\\"")) | ||
|
||
print("Found %s manifest strings" % len(strings)) | ||
if len(strings) > 0: | ||
with open(args.output, "w") as f: | ||
f.write("// Auto-generated with extract_plugin_manifest_strings.py, do not edit!\n\n") | ||
f.write("from django.utils.translation import gettext as _\n") | ||
|
||
for s in strings: | ||
f.write("_(\"%s\")\n" % s.replace("\"", "\\\"")) | ||
print("Wrote %s" % output) | ||
else: | ||
print("No strings found") | ||
|
||
print("Wrote %s" % args.output) | ||
else: | ||
print("No strings found") | ||
if __name__ == "__main__": | ||
import argparse | ||
parser = argparse.ArgumentParser(description='Extract plugin manifest strings.') | ||
parser.add_argument('input', type=str, | ||
help='Path to plugins directory') | ||
parser.add_argument('output', type=str, | ||
help='Where to write resulting translation file') | ||
args = parser.parse_args() | ||
extract_plugin_manifest_strings(args.input, args.output) |
Oops, something went wrong.