Ruff: safe fixes.

pull/1686/head
Mathijs de Bruin 2025-05-14 15:06:50 +01:00
rodzic 58d13ac681
commit 3c01abfc03
85 zmienionych plików z 158 dodań i 182 usunięć

Wyświetl plik

@ -24,7 +24,7 @@ from django import forms
from codemirror2.widgets import CodeMirrorEditor
from webodm import settings
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.utils.translation import gettext_lazy as _, gettext
from django.utils.translation import gettext_lazy as _
class ProjectAdmin(GuardedModelAdmin):

Wyświetl plik

@ -1,12 +1,11 @@
from django.contrib.auth.models import User, Group
from app.models import Profile
from rest_framework import serializers, viewsets, generics, status, exceptions
from rest_framework import serializers, viewsets, status, exceptions
from rest_framework.decorators import action
from rest_framework.permissions import IsAdminUser
from rest_framework.response import Response
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth.hashers import make_password
from app import models
class UserSerializer(serializers.ModelSerializer):
class Meta:

Wyświetl plik

@ -1,6 +1,5 @@
from django.core.exceptions import ObjectDoesNotExist
from rest_framework import exceptions
import os
import re
from app import models

Wyświetl plik

@ -1,7 +1,6 @@
from django.contrib.auth.models import User
from django.contrib.auth import login
from rest_framework.views import APIView
from rest_framework import exceptions, permissions, parsers
from rest_framework import permissions, parsers
from rest_framework.response import Response
from app.auth.backends import get_user_from_external_auth_response, cluster_mismatch
import requests

Wyświetl plik

@ -41,6 +41,6 @@ class PolygonGeometryField(Field):
return GEOSGeometry(value)
except GEOSException:
raise ValidationError('Invalid format: not GeoJSON')
except (ValueError, TypeError, GDALException) as e:
except (ValueError, TypeError, GDALException):
raise ValidationError('Unable to create GEOSGeometry')

Wyświetl plik

@ -4,7 +4,6 @@ import math
from .tasks import TaskNestedView
from rest_framework import exceptions
from app.models.task import assets_directory_path
from PIL import Image, ImageDraw, ImageOps
from django.http import HttpResponse
from .tasks import download_file_response

Wyświetl plik

@ -27,7 +27,7 @@ class Scene(TaskNestedView):
raise exceptions.ValidationError(detail="Invalid potree scene")
for k in scene:
if not k in ["view", "pointclouds", "settings"]:
if k not in ["view", "pointclouds", "settings"]:
task.potree_scene[k] = scene[k]
task.save()

Wyświetl plik

@ -96,6 +96,6 @@ class ProcessingNodeOptionsView(APIView):
if not found:
common_option['_delete'] = True
common_options = [co for co in common_options if not '_delete' in co]
common_options = [co for co in common_options if '_delete' not in co]
return Response(common_options)

Wyświetl plik

@ -9,7 +9,6 @@ from django.db import transaction
from django.contrib.auth.models import User
from django.contrib.postgres.search import SearchQuery, SearchVector
from django.contrib.postgres.aggregates import StringAgg
from django.db.models import Q
from app import models
from .tasks import TaskIDsSerializer
@ -187,16 +186,16 @@ class ProjectViewSet(viewsets.ModelViewSet):
continue
# Has permission in database but not in form?
if user.has_perm(perm, project) and not p in perms_map[username]:
if user.has_perm(perm, project) and p not in perms_map[username]:
remove_perm(perm, user, project)
# Has permission in form but not in database?
elif p in perms_map[username] and not user.has_perm(perm, project):
assign_perm(perm, user, project)
except User.DoesNotExist as e:
except User.DoesNotExist:
return Response({'error': _("Invalid user in permissions list")}, status=status.HTTP_400_BAD_REQUEST)
except AttributeError as e:
except AttributeError:
return Response({'error': _("Invalid permissions")}, status=status.HTTP_400_BAD_REQUEST)
return Response({'success': True}, status=status.HTTP_200_OK)

Wyświetl plik

@ -11,7 +11,7 @@ from PIL import Image
import io
import numpy as np
from shutil import copyfileobj, move
from shutil import copyfileobj
from django.core.exceptions import ObjectDoesNotExist, SuspiciousFileOperation, ValidationError
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.db import transaction

Wyświetl plik

@ -1,5 +1,4 @@
import json
import rio_tiler.utils
from rasterio.enums import ColorInterp
from rasterio.crs import CRS
from rasterio.features import bounds as featureBounds
@ -12,7 +11,7 @@ from rio_tiler.errors import TileOutsideBounds
from rio_tiler.utils import has_alpha_band, \
non_alpha_indexes, render, create_cutline
from rio_tiler.utils import _stats as raster_stats
from rio_tiler.models import ImageStatistics, ImageData
from rio_tiler.models import ImageStatistics
from rio_tiler.models import Metadata as RioMetadata
from rio_tiler.profiles import img_profiles
from rio_tiler.colormap import cmap as colormap, apply_cmap
@ -75,7 +74,7 @@ def get_extent(task, tile_type):
'dsm': task.dsm_extent,
'dtm': task.dtm_extent,
}
if not tile_type in extent_map:
if tile_type not in extent_map:
raise exceptions.NotFound()
extent = extent_map[tile_type]
@ -551,9 +550,9 @@ class Export(TaskNestedView):
expr = None
if asset_type in ['orthophoto', 'dsm', 'dtm'] and not export_format in ['gtiff', 'gtiff-rgb', 'jpg', 'png', 'kmz']:
if asset_type in ['orthophoto', 'dsm', 'dtm'] and export_format not in ['gtiff', 'gtiff-rgb', 'jpg', 'png', 'kmz']:
raise exceptions.ValidationError(_("Unsupported format: %(value)s") % {'value': export_format})
if asset_type == 'georeferenced_model' and not export_format in ['laz', 'las', 'ply', 'csv']:
if asset_type == 'georeferenced_model' and export_format not in ['laz', 'las', 'ply', 'csv']:
raise exceptions.ValidationError(_("Unsupported format: %(value)s") % {'value': export_format})
# Default color map, hillshade

Wyświetl plik

@ -1,9 +1,8 @@
import os
import sys
import kombu
from django.contrib.auth.models import Permission
from django.contrib.auth.models import User, Group
from django.contrib.auth.models import Group
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.core.files import File
from django.db.utils import ProgrammingError
@ -15,10 +14,8 @@ from app.models import Theme
from app.plugins import init_plugins
from nodeodm.models import ProcessingNode
# noinspection PyUnresolvedReferencesapp/boot.py#L20
from webodm.settings import MEDIA_ROOT
from . import signals
import logging
from .models import Task, Setting
from .models import Setting
from webodm import settings
from webodm.wsgi import booted

Wyświetl plik

@ -1,4 +1,3 @@
import glob
import os
import logging

Wyświetl plik

@ -1,4 +1,3 @@
import os
from django.core.management.base import BaseCommand
from nodeodm.models import ProcessingNode

Wyświetl plik

@ -1,6 +1,5 @@
import os
from django.core.management.base import BaseCommand
from django.core.management import call_command
from app.models import Project
from webodm import settings

Wyświetl plik

@ -1,7 +1,6 @@
import os
import shutil
from django.core.management.base import BaseCommand
from django.core.management import call_command
from app.models import Project
from webodm import settings

Wyświetl plik

@ -1,9 +1,6 @@
import os
import json
import math
from django.core.management.base import BaseCommand
from django.core.management import call_command
from app.models import Project
from webodm import settings
from django.db import connection

Wyświetl plik

@ -1,4 +1,3 @@
import os
from django.core.management.base import BaseCommand
import socket

Wyświetl plik

@ -3,9 +3,11 @@
from __future__ import unicode_literals
from django.db import migrations, models
import uuid, os, pickle, tempfile
import uuid
import os
import pickle
import tempfile
from webodm import settings
tasks = []
task_ids = {} # map old task IDs --> new task IDs

Wyświetl plik

@ -2,8 +2,10 @@
# Generated by Django 1.11.1 on 2017-11-30 15:41
from __future__ import unicode_literals
from django.db import migrations, models
import uuid, os, pickle, tempfile
from django.db import migrations
import os
import pickle
import tempfile
from webodm import settings

Wyświetl plik

@ -5,7 +5,6 @@ from __future__ import unicode_literals
from django.db import migrations, models
import uuid
from webodm import settings
class Migration(migrations.Migration):

Wyświetl plik

@ -4,7 +4,6 @@ from __future__ import unicode_literals
from django.db import migrations, models
from webodm import settings
class Migration(migrations.Migration):

Wyświetl plik

@ -2,9 +2,8 @@
# Generated by Django 1.11.1 on 2017-07-07 18:05
from __future__ import unicode_literals
import django.contrib.postgres.fields
import os
from django.db import migrations, models
from django.db import migrations
from webodm import settings

Wyświetl plik

@ -2,7 +2,6 @@
import rasterio
import os
import django.contrib.postgres.fields.jsonb
from django.db import migrations
from webodm import settings

Wyświetl plik

@ -8,7 +8,6 @@ import uuid as uuid_module
from zipstream.ng import ZipStream
import json
from shlex import quote
import errno
import piexif
@ -49,7 +48,6 @@ from .project import Project
from django.utils.translation import gettext_lazy as _, gettext
from functools import partial
import subprocess
from app.classes.console import Console
logger = logging.getLogger('app.logger')
@ -689,7 +687,7 @@ class Task(models.Model):
self.pending_action = None
self.save()
if self.auto_processing_node and not self.status in [status_codes.FAILED, status_codes.CANCELED]:
if self.auto_processing_node and self.status not in [status_codes.FAILED, status_codes.CANCELED]:
# No processing node assigned and need to auto assign
if self.processing_node is None:
# Assign first online node with lowest queue count
@ -801,7 +799,7 @@ class Task(models.Model):
# Good to go
try:
self.processing_node.restart_task(self.uuid, self.options)
except (NodeServerError, NodeResponseError) as e:
except (NodeServerError, NodeResponseError):
# Something went wrong
logger.warning("Could not restart {}, will start a new one".format(self))
need_to_reprocess = True
@ -948,9 +946,9 @@ class Task(models.Model):
self.set_failure(str(e))
except NodeConnectionError as e:
logger.warning("{} connection/timeout error: {}. We'll try reprocessing at the next tick.".format(self, str(e)))
except TaskInterruptedException as e:
except TaskInterruptedException:
# Task was interrupted during image resize / upload
logger.warning("{} interrupted".format(self, str(e)))
logger.warning("{} interrupted".format(self, ))
def extract_assets_and_complete(self):
"""

Wyświetl plik

@ -1,6 +1,4 @@
import logging
import os
from pathlib import Path
from django.db.models import signals
from django.db import models
@ -10,7 +8,6 @@ from django.utils.translation import gettext_lazy as _
from django.core.cache import cache
from django.core.cache.utils import make_template_fragment_key
from webodm import settings
logger = logging.getLogger('app.logger')

Wyświetl plik

@ -22,7 +22,7 @@ from app.security import path_traversal_check
logger = logging.getLogger('app.logger')
# Add additional python path to discover plugins
if not settings.MEDIA_ROOT in sys.path:
if settings.MEDIA_ROOT not in sys.path:
sys.path.append(settings.MEDIA_ROOT)
def init_plugins():
@ -100,7 +100,7 @@ def build_plugins():
# Check if we need to generate a webpack.config.js
if len(plugin.build_jsx_components()) > 0 and plugin.path_exists('public'):
build_paths = map(lambda p: os.path.join(plugin.get_path('public'), p), plugin.build_jsx_components())
paths_ok = not (False in map(lambda p: os.path.exists, build_paths))
paths_ok = False not in map(lambda p: os.path.exists, build_paths)
if paths_ok:
wpc_path = os.path.join(settings.BASE_DIR, 'app', 'plugins', 'templates', 'webpack.config.js.tmpl')

Wyświetl plik

@ -1,5 +1,8 @@
import json
import logging, os, sys, subprocess
import logging
import os
import sys
import subprocess
from abc import ABC
from app.plugins import UserDataStore, GlobalDataStore
from app.plugins.functions import get_plugins_persistent_path

Wyświetl plik

@ -1,11 +1,9 @@
import os
from app.api.tasks import TaskNestedView as TaskView
from app.api.workers import CheckTask as CheckTask
from app.api.workers import GetTaskResult as GetTaskResult
from app.api.workers import TaskResultOutputError
from django.http import HttpResponse, Http404
from django.http import Http404
from .functions import get_plugin_by_name, get_active_plugins
from django.conf.urls import url
from django.views.static import serve

Wyświetl plik

@ -1,7 +1,8 @@
#!/usr/bin/python3
import argparse, os, urllib.request, ast, sys
from io import StringIO
import argparse
import urllib.request
import ast
# Misc variables needed to get config to run
__version__ = '?'

Wyświetl plik

@ -1,6 +1,8 @@
#!/usr/bin/python3
import json, os, glob
import json
import os
import glob
def extract_plugin_manifest_strings(plugins_dir, output):
strings = []

Wyświetl plik

@ -1,6 +1,6 @@
#!/usr/bin/python3
import json, os
import json
def extract_potree_strings(translation_json, output):
strings = []

Wyświetl plik

@ -1,6 +1,5 @@
import os
from django import db
from django.contrib.auth.models import User
from django.test import TestCase
from django.test import TransactionTestCase

Wyświetl plik

@ -1,4 +1,3 @@
import http.server
from http.server import SimpleHTTPRequestHandler
import socketserver
import sys
@ -28,7 +27,7 @@ class MyHandler(SimpleHTTPRequestHandler):
def do_POST(self):
if self.path == '/auth':
if not 'Content-Length' in self.headers:
if 'Content-Length' not in self.headers:
self.send_error(403, "Missing form data")
return

Wyświetl plik

@ -8,7 +8,6 @@ from rest_framework import status
from rest_framework.test import APIClient
from rest_framework_jwt.settings import api_settings
from app import pending_actions
from app.models import Project, Task
from app.plugins.signals import processing_node_removed
from app.tests.utils import catch_signal

Wyświetl plik

@ -6,7 +6,7 @@ from rest_framework_jwt.settings import api_settings
from django.contrib.auth.hashers import check_password
from .classes import BootTestCase
from app.api.admin import UserSerializer, GroupSerializer
from app.api.admin import GroupSerializer
class TestApi(BootTestCase):

Wyświetl plik

@ -1,15 +1,10 @@
import os
import time
from worker.celery import app as celery
import logging
import json
import requests
from PIL import Image
from django.contrib.auth.models import User
from rest_framework import status
from rest_framework.test import APIClient
from app.plugins.signals import task_completed
from app.tests.classes import BootTransactionTestCase
from app.models import Project, Task
from nodeodm.models import ProcessingNode
@ -19,13 +14,12 @@ from nodeodm import status_codes
import worker
from worker.tasks import TestSafeAsyncResult
from .utils import start_processing_node, clear_test_media_root, catch_signal
from .utils import start_processing_node, clear_test_media_root
# We need to test in a TransactionTestCase because
# task processing happens on a separate thread, and normal TestCases
# do not commit changes to the DB, so spawning a new thread will show no
# data in it.
from webodm import settings
logger = logging.getLogger('app.logger')
DELAY = 2 # time to sleep for during process launch, background processing, etc.

Wyświetl plik

@ -7,7 +7,6 @@ from app.models import Project
from .classes import BootTestCase
from guardian.shortcuts import get_perms
from webodm import settings
logger = logging.getLogger('app.logger')

Wyświetl plik

@ -1,6 +1,5 @@
import logging
import json
from django.contrib.auth.models import User
from rest_framework import status
from rest_framework.test import APIClient

Wyświetl plik

@ -2,9 +2,7 @@ import io
import os
import time
import threading
from worker.celery import app as celery
import logging
from datetime import timedelta
@ -90,7 +88,7 @@ class TestApiTask(BootTransactionTestCase):
res = client.post("/api/projects/{}/tasks/".format(project.id), {
'images': [image1, image2]
}, format="multipart")
self.assertTrue(res.status_code == status.HTTP_403_FORBIDDEN);
self.assertTrue(res.status_code == status.HTTP_403_FORBIDDEN)
image1.seek(0)
image2.seek(0)
@ -1285,7 +1283,7 @@ class TestApiTask(BootTransactionTestCase):
'auto_processing_node': 'true',
'partial': 'true'
}, format="multipart")
self.assertTrue(res.status_code == status.HTTP_403_FORBIDDEN);
self.assertTrue(res.status_code == status.HTTP_403_FORBIDDEN)
client.login(username="testuser", password="test1234")

Wyświetl plik

@ -1,8 +1,6 @@
import os
import time
import io
import requests
from django.contrib.auth.models import User
from guardian.shortcuts import remove_perm, assign_perm
from rest_framework import status

Wyświetl plik

@ -2,10 +2,8 @@ import logging
from django.contrib.auth.models import User
from rest_framework import status
from rest_framework.test import APIClient
from app.models import Project
from .classes import BootTestCase
from webodm import settings
logger = logging.getLogger('app.logger')

Wyświetl plik

@ -1,5 +1,4 @@
from django.contrib.auth.models import User, Group
from rest_framework import status
from django.contrib.auth.models import User
from rest_framework.test import APIClient
from app.models import Task, Project
from django.utils import timezone

Wyświetl plik

@ -1,6 +1,5 @@
import logging
import json
from django.contrib.auth.models import User
from rest_framework import status
from rest_framework.test import APIClient

Wyświetl plik

@ -1,6 +1,5 @@
from django.contrib.auth.models import User, Group
from django.contrib.auth.models import User
from nodeodm.models import ProcessingNode
from rest_framework import status
from rest_framework.test import APIClient
from .classes import BootTestCase

Wyświetl plik

@ -1,4 +1,3 @@
import os
from django.test import Client
from webodm import settings
from .classes import BootTestCase

Wyświetl plik

@ -1,8 +1,6 @@
from django.contrib.auth.models import User, Group
from rest_framework import status
from django.contrib.auth.models import User
from rest_framework.test import APIClient
from app.models import Task, Project
from nodeodm.models import ProcessingNode
from worker.tasks import check_quotas
from .classes import BootTestCase

Wyświetl plik

@ -1,5 +1,4 @@
import os
import time
from django.core.exceptions import ValidationError
from django.core.files import File

Wyświetl plik

@ -1,7 +1,4 @@
import os
import re
from django.contrib.staticfiles import finders
from django.test import Client
from .classes import BootTestCase

Wyświetl plik

@ -5,7 +5,6 @@ from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import User
from django.http import Http404
from django.shortcuts import render, redirect, get_object_or_404
from guardian.shortcuts import get_objects_for_user
from nodeodm.models import ProcessingNode
from app.models import Project, Task

Wyświetl plik

@ -2,14 +2,20 @@ from django.http import Http404
from django.contrib.auth.decorators import user_passes_test
from django.shortcuts import render
from django.contrib import messages
from django.utils.translation import ugettext as _
from django import forms
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, pathlib
import json
import tempfile
import os
import logging
import shutil
import subprocess
import zipfile
import glob
import pathlib
logger = logging.getLogger('app.logger')

Wyświetl plik

@ -2,7 +2,6 @@ import json
from django.http import Http404
from django.http import JsonResponse
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext as _
from django.shortcuts import render
from app.api.tasks import TaskSerializer

Wyświetl plik

@ -1,8 +1,4 @@
import sys
import time
import logging
import requests
from os import path
from enum import Enum
from itertools import chain as iter_chain
@ -15,7 +11,6 @@ from worker.celery import app
from django.dispatch import receiver
from django.utils.translation import ugettext_lazy as _
from rest_framework.fields import ChoiceField, CharField, JSONField
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from rest_framework import serializers
@ -68,7 +63,6 @@ def get_processing_assets(task_id):
ispc = app.control.inspect()
ion_tasks = set()
active = set()
from uuid import UUID
for wtask in iter_chain(*ispc.active().values(), *ispc.reserved().values()):
args = eval(wtask["args"])

Wyświetl plik

@ -1,5 +1,4 @@
import json
import requests
from django import forms
from django.contrib import messages

Wyświetl plik

@ -1,7 +1,5 @@
import re
import json
from app.plugins import PluginBase, Menu, MountPoint, logger
from app.plugins import PluginBase, Menu, MountPoint
from .globals import PROJECT_NAME
from .api_views import ShareTaskView, RefreshIonTaskView, ClearErrorsTaskView

Wyświetl plik

@ -17,7 +17,6 @@ def upload_to_ion(
import requests
from os import path, remove
from shutil import rmtree
from enum import Enum
from app.plugins import logger
try:
@ -101,7 +100,7 @@ def upload_to_ion(
except ImportError:
import subprocess
asset_logger.info(f"Manually installing boto3...")
asset_logger.info("Manually installing boto3...")
subprocess.call([sys.executable, "-m", "pip", "install", "boto3"])
import boto3
@ -112,7 +111,7 @@ def upload_to_ion(
generated_zipfile = asset_path
asset_path, del_directory = to_ion_texture_model(asset_path)
logger.info("Created ion texture model!")
except IonInvalidZip as e:
except IonInvalidZip:
logger.info("Non geo-referenced texture model, using default file.")
except Exception as e:
logger.warning(f"Failed to convert to ion texture model: {e}")
@ -183,7 +182,7 @@ def upload_to_ion(
state, percent_complete = pluck(res.json(), "status", "percentComplete")
progress = float(percent_complete) / 100
if "ERROR" in state.upper():
asset_info["error"] = f"Processing failed"
asset_info["error"] = "Processing failed"
asset_logger.info("Processing failed...")
refresh = False
if progress >= 1:

Wyświetl plik

@ -1,14 +1,10 @@
import importlib
import requests
import os
from os import path
from app import models, pending_actions
from app.plugins.views import TaskView
from app.plugins.worker import run_function_async
from app.plugins import get_current_plugin
from worker.celery import app
from rest_framework.response import Response
from rest_framework import status
@ -100,8 +96,6 @@ class PlatformsTaskView(TaskView):
def import_files(task_id, files):
import requests
from app import models
from app.plugins import logger
from app.security import path_traversal_check

Wyświetl plik

@ -1,12 +1,9 @@
import requests
from django import forms
from django.contrib import messages
from django.http import HttpResponse
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from app.plugins import logger
from .platform_helper import get_all_extended_platforms

Wyświetl plik

@ -1,5 +1,4 @@
from abc import ABC, abstractmethod
from app.plugins import get_current_plugin
from coreplugins.cloudimport.cloud_platform import CloudPlatform
class PlatformExtension(CloudPlatform):

Wyświetl plik

@ -1,8 +1,6 @@
# Check https://github.com/
from urllib.parse import urlparse
from os import path
from coreplugins.cloudimport.cloud_platform import File, Folder, CloudPlatform
from app.plugins import logger
class Platform(CloudPlatform):
def __init__(self):

Wyświetl plik

@ -18,12 +18,12 @@ class Platform(CloudLibrary):
def parse_url(self, url):
parse_result = urlparse(url)
paths = parse_result.query.split('/')
if not 'category' in paths or paths.index('category') >= len(paths) - 1:
if 'category' not in paths or paths.index('category') >= len(paths) - 1:
raise Exception('Wrong URL format')
else:
category_id = paths[paths.index('category') + 1]
path = parse_result.path
if not 'index.php' in path:
if 'index.php' not in path:
raise Exception('Wrong URL format')
path = path[0:path.index('index.php')]

Wyświetl plik

@ -1,4 +1,4 @@
from app.plugins import PluginBase, Menu, MountPoint, logger
from app.plugins import PluginBase, Menu, MountPoint
from .api_views import PlatformsTaskView, PlatformsVerifyTaskView, ImportFolderTaskView, CheckUrlTaskView
from .app_views import HomeView, LoadButtonsView

Wyświetl plik

@ -2,7 +2,7 @@ import os
from rest_framework import status
from rest_framework.response import Response
from app.plugins.views import TaskView, CheckTask, GetTaskResult
from app.plugins.views import TaskView, GetTaskResult
from app.plugins.worker import run_function_async
from django.utils.translation import gettext_lazy as _
@ -15,7 +15,6 @@ def calc_contours(dem, epsg, interval, output_format, simplify, zfactor = 1, cro
import tempfile
import shutil
import glob
import json
from webodm import settings
ext = ""
@ -59,7 +58,7 @@ def calc_contours(dem, epsg, interval, output_format, simplify, zfactor = 1, cro
dem = dem_vrt
contours_file = f"contours.gpkg"
contours_file = "contours.gpkg"
p = subprocess.Popen([gdal_contour_bin, "-q", "-a", "level", "-3d", "-f", "GPKG", "-i", str(interval), dem, contours_file], cwd=tmpdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
@ -121,7 +120,7 @@ class TaskContoursGenerate(TaskView):
interval = float(request.data.get('interval', 1))
format = request.data.get('format', 'GPKG')
supported_formats = ['GPKG', 'ESRI Shapefile', 'DXF', 'GeoJSON']
if not format in supported_formats:
if format not in supported_formats:
raise ContoursException("Invalid format {} (must be one of: {})".format(format, ",".join(supported_formats)))
simplify = float(request.data.get('simplify', 0.01))
zfactor = float(request.data.get('zfactor', 1))

Wyświetl plik

@ -3,7 +3,7 @@ from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.utils.translation import gettext as _
import json, shutil
import shutil
def get_memory_stats():
"""

Wyświetl plik

@ -1,6 +1,4 @@
from genericpath import isfile
import importlib
import json
from posixpath import join
import time
import requests
@ -12,13 +10,12 @@ from app.security import path_traversal_check
from app.plugins.views import TaskView
from app.plugins.worker import run_function_async, task
from app.plugins import get_current_plugin
from app.plugins import GlobalDataStore, get_site_settings, signals as plugin_signals
from app.plugins import signals as plugin_signals
from coreplugins.dronedb.ddb import DEFAULT_HUB_URL, DroneDB, parse_url, verify_url
from django.dispatch import receiver
from worker.celery import app
from rest_framework.response import Response
from rest_framework import status
@ -205,10 +202,7 @@ class ImportDatasetTaskView(TaskView):
return Response({}, status=status.HTTP_200_OK)
def import_files(task_id, carrier):
import requests
from app import models
from app.plugins import logger
from app.security import path_traversal_check
files = carrier['files']
@ -321,7 +315,6 @@ DRONEDB_ASSETS = [
class ShareTaskView(TaskView):
def post(self, request, pk):
from app.plugins import logger
task = self.get_and_check_task(request, pk)

Wyświetl plik

@ -1,12 +1,6 @@
import requests
from django import forms
from django.contrib import messages
from django.http import HttpResponse
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from app.plugins import logger
def LoadButtonsView(plugin):
def view(request):

Wyświetl plik

@ -1,6 +1,4 @@
from functools import reduce
import requests
from os import path
from app.plugins import logger
from urllib.parse import urlparse

Wyświetl plik

@ -1,4 +1,4 @@
from app.plugins import PluginBase, Menu, MountPoint, logger
from app.plugins import PluginBase, Menu, MountPoint
from coreplugins.dronedb.app_views import LoadButtonsView
from coreplugins.dronedb.ddb import DEFAULT_HUB_URL

Wyświetl plik

@ -1,11 +1,8 @@
import math
import re
from rest_framework import status
from rest_framework.response import Response
from app.plugins.views import TaskView
from app.plugins import get_current_plugin, signals as plugin_signals
from django.dispatch import receiver
from app.plugins import GlobalDataStore
from django.http import Http404
from django.shortcuts import redirect

Wyświetl plik

@ -1,7 +1,4 @@
from app.plugins import PluginBase, Menu, MountPoint
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.utils.translation import gettext as _
from app.plugins import PluginBase, MountPoint
from .api import GetShortLink, EditShortLink, DeleteShortLink, HandleShortLink
class Plugin(PluginBase):

Wyświetl plik

@ -3,7 +3,6 @@ import json
from django.dispatch import receiver
from django.http import HttpResponse
from guardian.shortcuts import get_objects_for_user, assign_perm
from rest_framework.renderers import JSONRenderer
from django.utils.translation import gettext as _
from app.plugins import GlobalDataStore, logger

Wyświetl plik

@ -2,7 +2,7 @@ import os
from rest_framework import serializers
from rest_framework import status
from rest_framework.response import Response
from app.api.workers import GetTaskResult, TaskResultOutputError
from app.api.workers import GetTaskResult
from app.models import Task
from app.plugins.views import TaskView
from django.utils.translation import gettext_lazy as _

Wyświetl plik

@ -8,7 +8,6 @@ def calc_volume(input_dem, pts=None, pts_epsg=None, geojson_polygon=None, decima
from scipy.optimize import curve_fit
from scipy.interpolate import griddata
import numpy as np
import json
import warnings
osr.UseExceptions()
@ -124,7 +123,7 @@ def read_polygon(file):
features = [data]
for feature in features:
if not 'geometry' in feature:
if 'geometry' not in feature:
continue
# Check if the feature geometry type is Polygon

Wyświetl plik

@ -68,7 +68,7 @@ class TaskObjDetect(TaskView):
'planes': ('aerovision', ['plane']),
}
if not model in model_map:
if model not in model_map:
return Response({'error': 'Invalid model'}, status=status.HTTP_200_OK)
model_id, classes = model_map[model]

Wyświetl plik

@ -13,7 +13,6 @@ from app.plugins import GlobalDataStore, get_site_settings, signals as plugin_si
from app.plugins.views import TaskView
from app.plugins.worker import task
from webodm import settings
from django.dispatch import receiver
import requests
@ -66,7 +65,7 @@ class Info(TaskView):
# TODO: for better data we could look over all images
# and find actual end and start time
# Here we're picking an image at random and assuming a one hour flight
if not 'sensor' in task_info:
if 'sensor' not in task_info:
task_info['endDate'] = datetime.utcnow().timestamp() * 1000
task_info['sensor'] = ''
task_info['title'] = task.name

Wyświetl plik

@ -1,5 +1,4 @@
from app.plugins import PluginBase, Menu, MountPoint
from django.shortcuts import render
from app.plugins import PluginBase
class Plugin(PluginBase):
def include_js_files(self):

Wyświetl plik

@ -1,9 +1,8 @@
import math
from rest_framework import status
from rest_framework.response import Response
from app.plugins.views import TaskView
from app.plugins import get_current_plugin, signals as plugin_signals
from app.plugins import signals as plugin_signals
from django.dispatch import receiver
from app.plugins import GlobalDataStore
from django.http import Http404

Wyświetl plik

@ -1,7 +1,4 @@
from app.plugins import PluginBase, Menu, MountPoint
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.utils.translation import gettext as _
from app.plugins import PluginBase, MountPoint
from .api import GetShortLink, HandleShortLink
class Plugin(PluginBase):

Wyświetl plik

@ -67,11 +67,11 @@ class ConfigurationForm(forms.Form):
settings = Setting.objects.first()
email.send(f'{self.cleaned_data["notification_app_name"]} - Testing Notification', 'Hi, just testing if notification is working', self.cleaned_data)
messages.success(request, f"Email sent successfully, check your inbox at {self.cleaned_data.get('smtp_to_address')}")
except SMTPAuthenticationError as e:
except SMTPAuthenticationError:
messages.error(request, 'Invalid SMTP username or password')
except SMTPConnectError as e:
except SMTPConnectError:
messages.error(request, 'Could not connect to the SMTP server')
except SMTPDataError as e:
except SMTPDataError:
messages.error(request, 'Error sending email. Please try again later')
except Exception as e:
messages.error(request, f'An error occured: {e}')

Wyświetl plik

@ -1,6 +1,5 @@
import logging
from django.dispatch import receiver
from django.core.mail import send_mail
from app.plugins.signals import task_completed, task_failed, task_removed
from app.plugins.functions import get_current_plugin
from . import email as notification

Wyświetl plik

@ -0,0 +1,65 @@
# This configuration does not include a processing node
# Which makes for faster setup times
version: '2.1'
volumes:
dbdata:
appmedia:
services:
db:
image: opendronemap/webodm_db
container_name: db
expose:
- "5432"
volumes:
- dbdata:/var/lib/postgresql/data:Z
restart: unless-stopped
oom_score_adj: -100
mem_limit: 256M
mem_reservation: 64M
webapp:
image: opendronemap/webodm_webapp
container_name: webapp
entrypoint: /bin/bash -c "chmod +x /webodm/*.sh && /bin/bash -c \"/webodm/wait-for-postgres.sh db /webodm/wait-for-it.sh -t 0 broker:6379 -- /webodm/start.sh\""
volumes:
- appmedia:/webodm/app/media:z
ports:
- "2948:8000"
depends_on:
- db
- broker
- worker
environment:
WO_HOST: odm.dokterbob.net
WO_PORT: 2948
WO_DEBUG: NO
WO_BROKER: redis://broker
WO_DEV: NO
restart: unless-stopped
oom_score_adj: 0
mem_limit: 384M
mem_reservation: 128M
broker:
image: redis:7.0.10
container_name: broker
restart: unless-stopped
oom_score_adj: -500
mem_limit: 128M
mem_reservation: 32M
command: redis-server --maxmemory 100mb --maxmemory-policy allkeys-lru
worker:
image: opendronemap/webodm_webapp
container_name: worker
entrypoint: /bin/bash -c "/webodm/wait-for-postgres.sh db /webodm/wait-for-it.sh -t 0 broker:6379 -- /webodm/wait-for-it.sh -t 0 webapp:8000 -- /webodm/worker.sh start"
volumes:
- appmedia:/webodm/app/media:z
depends_on:
- db
- broker
environment:
WO_DEBUG: NO
WO_BROKER: redis://broker
WO_SECRET_KEY: pO/7WTFJwqFM5UWtu6BVTiQVPNVogsOBasiWhbSys0t/ESAGgyXaFaNOqVilAFfkMa4=
restart: unless-stopped
oom_score_adj: 250
mem_limit: 256M
mem_reservation: 64M

Wyświetl plik

@ -1,7 +1,6 @@
import os
from datetime import timedelta, datetime
import requests
from django.test import TestCase
from django.utils import six
import time

Wyświetl plik

@ -1,3 +1,2 @@
from django.shortcuts import render
# Create your views here.

Wyświetl plik

@ -6,7 +6,12 @@ https://mozilla.org/MPL/2.0/.
'''
# How to authenticate and process drone images using WebODM
import requests, sys, os, glob, json, time
import requests
import sys
import os
import glob
import json
import time
import status_codes
if len(sys.argv) < 2:

Wyświetl plik

@ -10,7 +10,9 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os, sys, json
import os
import sys
import json
import datetime