From 3c01abfc03a50dee0977881e2285bf24aad3cabe Mon Sep 17 00:00:00 2001 From: Mathijs de Bruin Date: Wed, 14 May 2025 15:06:50 +0100 Subject: [PATCH] Ruff: safe fixes. --- app/admin.py | 2 +- app/api/admin.py | 3 +- app/api/common.py | 1 - app/api/externalauth.py | 3 +- app/api/fields.py | 2 +- app/api/imageuploads.py | 1 - app/api/potree.py | 2 +- app/api/processingnodes.py | 2 +- app/api/projects.py | 7 +- app/api/tasks.py | 2 +- app/api/tiler.py | 9 ++- app/boot.py | 7 +- app/classes/gcp.py | 1 - app/management/commands/addnode.py | 1 - app/management/commands/borg.py | 1 - app/management/commands/cleanup.py | 1 - app/management/commands/cluster.py | 3 - app/management/commands/getnodehostname.py | 1 - app/migrations/0012_public_task_uuids.py | 6 +- app/migrations/0013_public_task_uuids.py | 6 +- app/migrations/0014_public_task_uuids.py | 1 - app/migrations/0016_public_task_uuids.py | 1 - app/migrations/0024_update_task_assets.py | 3 +- app/migrations/0039_task_orthophoto_bands.py | 1 - app/models/task.py | 10 ++- app/models/theme.py | 3 - app/plugins/functions.py | 4 +- app/plugins/plugin_base.py | 5 +- app/plugins/views.py | 4 +- app/scripts/extract_odm_strings.py | 5 +- .../extract_plugin_manifest_strings.py | 4 +- app/scripts/extract_potree_strings.py | 2 +- app/tests/classes.py | 1 - app/tests/scripts/simple_auth_server.py | 3 +- app/tests/test_api.py | 1 - app/tests/test_api_admin.py | 2 +- app/tests/test_api_export.py | 8 +-- app/tests/test_api_projects.py | 1 - app/tests/test_api_tags.py | 1 - app/tests/test_api_task.py | 6 +- app/tests/test_api_task_import.py | 2 - app/tests/test_api_users.py | 2 - app/tests/test_cleanup.py | 3 +- app/tests/test_crop.py | 1 - app/tests/test_external_auth.py | 3 +- app/tests/test_login.py | 1 - app/tests/test_quota.py | 4 +- app/tests/test_settings.py | 1 - app/tests/test_theme.py | 3 - app/views/app.py | 1 - app/views/dev.py | 12 +++- app/views/public.py | 1 - coreplugins/cesiumion/api_views.py | 6 -- coreplugins/cesiumion/app_views.py | 1 - coreplugins/cesiumion/plugin.py | 4 +- coreplugins/cesiumion/uploader.py | 7 +- coreplugins/cloudimport/api_views.py | 6 -- coreplugins/cloudimport/app_views.py | 3 - coreplugins/cloudimport/platform_extension.py | 1 - coreplugins/cloudimport/platforms/github.py | 2 - coreplugins/cloudimport/platforms/piwigo.py | 4 +- coreplugins/cloudimport/plugin.py | 2 +- coreplugins/contours/api.py | 7 +- coreplugins/diagnostic/plugin.py | 2 +- coreplugins/dronedb/api_views.py | 9 +-- coreplugins/dronedb/app_views.py | 6 -- coreplugins/dronedb/ddb.py | 2 - coreplugins/dronedb/plugin.py | 2 +- coreplugins/editshortlinks/api.py | 3 - coreplugins/editshortlinks/plugin.py | 5 +- coreplugins/lightning/plugin.py | 1 - coreplugins/measure/api.py | 2 +- coreplugins/measure/volume.py | 3 +- coreplugins/objdetect/api.py | 2 +- coreplugins/openaerialmap/api.py | 3 +- coreplugins/osm-quickedit/plugin.py | 3 +- coreplugins/shortlinks/api.py | 3 +- coreplugins/shortlinks/plugin.py | 5 +- coreplugins/tasknotification/plugin.py | 6 +- coreplugins/tasknotification/signals.py | 1 - docker-compose.yml.bacalhau | 65 +++++++++++++++++++ nodeodm/tests.py | 1 - nodeodm/views.py | 1 - slate/examples/process_images.py | 7 +- webodm/settings.py | 4 +- 85 files changed, 158 insertions(+), 182 deletions(-) create mode 100644 docker-compose.yml.bacalhau diff --git a/app/admin.py b/app/admin.py index 565c457c..20aaa025 100644 --- a/app/admin.py +++ b/app/admin.py @@ -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): diff --git a/app/api/admin.py b/app/api/admin.py index 15e136a2..09541187 100644 --- a/app/api/admin.py +++ b/app/api/admin.py @@ -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: diff --git a/app/api/common.py b/app/api/common.py index 4ad282e4..a370e325 100644 --- a/app/api/common.py +++ b/app/api/common.py @@ -1,6 +1,5 @@ from django.core.exceptions import ObjectDoesNotExist from rest_framework import exceptions -import os import re from app import models diff --git a/app/api/externalauth.py b/app/api/externalauth.py index 20ead5fa..154eb9ee 100644 --- a/app/api/externalauth.py +++ b/app/api/externalauth.py @@ -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 diff --git a/app/api/fields.py b/app/api/fields.py index b08c1462..96758cd6 100644 --- a/app/api/fields.py +++ b/app/api/fields.py @@ -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') diff --git a/app/api/imageuploads.py b/app/api/imageuploads.py index 1e3eba59..7a3f7706 100644 --- a/app/api/imageuploads.py +++ b/app/api/imageuploads.py @@ -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 diff --git a/app/api/potree.py b/app/api/potree.py index 181c8824..1207008b 100644 --- a/app/api/potree.py +++ b/app/api/potree.py @@ -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() diff --git a/app/api/processingnodes.py b/app/api/processingnodes.py index 9195714a..326f1be1 100644 --- a/app/api/processingnodes.py +++ b/app/api/processingnodes.py @@ -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) \ No newline at end of file diff --git a/app/api/projects.py b/app/api/projects.py index 91d4a47e..7e8abdcb 100644 --- a/app/api/projects.py +++ b/app/api/projects.py @@ -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) diff --git a/app/api/tasks.py b/app/api/tasks.py index 2786ab5b..c64f4a8a 100644 --- a/app/api/tasks.py +++ b/app/api/tasks.py @@ -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 diff --git a/app/api/tiler.py b/app/api/tiler.py index 79f31dcf..830dd513 100644 --- a/app/api/tiler.py +++ b/app/api/tiler.py @@ -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 diff --git a/app/boot.py b/app/boot.py index 0ef32bcf..0e618f81 100644 --- a/app/boot.py +++ b/app/boot.py @@ -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 diff --git a/app/classes/gcp.py b/app/classes/gcp.py index fe1df73d..049ec506 100644 --- a/app/classes/gcp.py +++ b/app/classes/gcp.py @@ -1,4 +1,3 @@ -import glob import os import logging diff --git a/app/management/commands/addnode.py b/app/management/commands/addnode.py index 70b363d5..db0442b5 100644 --- a/app/management/commands/addnode.py +++ b/app/management/commands/addnode.py @@ -1,4 +1,3 @@ -import os from django.core.management.base import BaseCommand from nodeodm.models import ProcessingNode diff --git a/app/management/commands/borg.py b/app/management/commands/borg.py index e0306c83..5962e97a 100644 --- a/app/management/commands/borg.py +++ b/app/management/commands/borg.py @@ -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 diff --git a/app/management/commands/cleanup.py b/app/management/commands/cleanup.py index 69dc8a7a..7837e38a 100644 --- a/app/management/commands/cleanup.py +++ b/app/management/commands/cleanup.py @@ -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 diff --git a/app/management/commands/cluster.py b/app/management/commands/cluster.py index a683bfda..49367e6b 100644 --- a/app/management/commands/cluster.py +++ b/app/management/commands/cluster.py @@ -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 diff --git a/app/management/commands/getnodehostname.py b/app/management/commands/getnodehostname.py index 651bcd93..99f9816a 100644 --- a/app/management/commands/getnodehostname.py +++ b/app/management/commands/getnodehostname.py @@ -1,4 +1,3 @@ -import os from django.core.management.base import BaseCommand import socket diff --git a/app/migrations/0012_public_task_uuids.py b/app/migrations/0012_public_task_uuids.py index 73919178..da8b73fb 100644 --- a/app/migrations/0012_public_task_uuids.py +++ b/app/migrations/0012_public_task_uuids.py @@ -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 diff --git a/app/migrations/0013_public_task_uuids.py b/app/migrations/0013_public_task_uuids.py index 7486a82e..21d80faf 100644 --- a/app/migrations/0013_public_task_uuids.py +++ b/app/migrations/0013_public_task_uuids.py @@ -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 diff --git a/app/migrations/0014_public_task_uuids.py b/app/migrations/0014_public_task_uuids.py index 9846829f..10243abd 100644 --- a/app/migrations/0014_public_task_uuids.py +++ b/app/migrations/0014_public_task_uuids.py @@ -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): diff --git a/app/migrations/0016_public_task_uuids.py b/app/migrations/0016_public_task_uuids.py index cc34e4e4..fc3caa3a 100644 --- a/app/migrations/0016_public_task_uuids.py +++ b/app/migrations/0016_public_task_uuids.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals from django.db import migrations, models -from webodm import settings class Migration(migrations.Migration): diff --git a/app/migrations/0024_update_task_assets.py b/app/migrations/0024_update_task_assets.py index e3cc40b4..a4bbbfe6 100644 --- a/app/migrations/0024_update_task_assets.py +++ b/app/migrations/0024_update_task_assets.py @@ -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 diff --git a/app/migrations/0039_task_orthophoto_bands.py b/app/migrations/0039_task_orthophoto_bands.py index c801ab85..14d929b7 100644 --- a/app/migrations/0039_task_orthophoto_bands.py +++ b/app/migrations/0039_task_orthophoto_bands.py @@ -2,7 +2,6 @@ import rasterio import os -import django.contrib.postgres.fields.jsonb from django.db import migrations from webodm import settings diff --git a/app/models/task.py b/app/models/task.py index acc83f8d..c2921f5b 100644 --- a/app/models/task.py +++ b/app/models/task.py @@ -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): """ diff --git a/app/models/theme.py b/app/models/theme.py index 28aa7367..a5be72b7 100644 --- a/app/models/theme.py +++ b/app/models/theme.py @@ -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') diff --git a/app/plugins/functions.py b/app/plugins/functions.py index e4f65513..65b3eec3 100644 --- a/app/plugins/functions.py +++ b/app/plugins/functions.py @@ -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') diff --git a/app/plugins/plugin_base.py b/app/plugins/plugin_base.py index ba7afae4..1c27cb66 100644 --- a/app/plugins/plugin_base.py +++ b/app/plugins/plugin_base.py @@ -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 diff --git a/app/plugins/views.py b/app/plugins/views.py index c3d16a7e..1b366244 100644 --- a/app/plugins/views.py +++ b/app/plugins/views.py @@ -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 diff --git a/app/scripts/extract_odm_strings.py b/app/scripts/extract_odm_strings.py index 88546be6..e75fe5a5 100644 --- a/app/scripts/extract_odm_strings.py +++ b/app/scripts/extract_odm_strings.py @@ -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__ = '?' diff --git a/app/scripts/extract_plugin_manifest_strings.py b/app/scripts/extract_plugin_manifest_strings.py index 9f545a00..d440709f 100644 --- a/app/scripts/extract_plugin_manifest_strings.py +++ b/app/scripts/extract_plugin_manifest_strings.py @@ -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 = [] diff --git a/app/scripts/extract_potree_strings.py b/app/scripts/extract_potree_strings.py index 320e4aa6..ffd55230 100644 --- a/app/scripts/extract_potree_strings.py +++ b/app/scripts/extract_potree_strings.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -import json, os +import json def extract_potree_strings(translation_json, output): strings = [] diff --git a/app/tests/classes.py b/app/tests/classes.py index 881e5dfd..1574eb2a 100644 --- a/app/tests/classes.py +++ b/app/tests/classes.py @@ -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 diff --git a/app/tests/scripts/simple_auth_server.py b/app/tests/scripts/simple_auth_server.py index 690b8636..18f9f61e 100644 --- a/app/tests/scripts/simple_auth_server.py +++ b/app/tests/scripts/simple_auth_server.py @@ -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 diff --git a/app/tests/test_api.py b/app/tests/test_api.py index 3fd45518..6e00c161 100644 --- a/app/tests/test_api.py +++ b/app/tests/test_api.py @@ -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 diff --git a/app/tests/test_api_admin.py b/app/tests/test_api_admin.py index a2c46b38..cfad3056 100644 --- a/app/tests/test_api_admin.py +++ b/app/tests/test_api_admin.py @@ -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): diff --git a/app/tests/test_api_export.py b/app/tests/test_api_export.py index 96cac69f..acfe2b8a 100644 --- a/app/tests/test_api_export.py +++ b/app/tests/test_api_export.py @@ -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. diff --git a/app/tests/test_api_projects.py b/app/tests/test_api_projects.py index c1d2d349..40f55ab0 100644 --- a/app/tests/test_api_projects.py +++ b/app/tests/test_api_projects.py @@ -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') diff --git a/app/tests/test_api_tags.py b/app/tests/test_api_tags.py index 7852358b..b9ddf5c0 100644 --- a/app/tests/test_api_tags.py +++ b/app/tests/test_api_tags.py @@ -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 diff --git a/app/tests/test_api_task.py b/app/tests/test_api_task.py index 4eb023e5..bfa26ea3 100644 --- a/app/tests/test_api_task.py +++ b/app/tests/test_api_task.py @@ -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") diff --git a/app/tests/test_api_task_import.py b/app/tests/test_api_task_import.py index 9f62cf64..0079af79 100644 --- a/app/tests/test_api_task_import.py +++ b/app/tests/test_api_task_import.py @@ -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 diff --git a/app/tests/test_api_users.py b/app/tests/test_api_users.py index 2eaf9547..7cc18ee4 100644 --- a/app/tests/test_api_users.py +++ b/app/tests/test_api_users.py @@ -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') diff --git a/app/tests/test_cleanup.py b/app/tests/test_cleanup.py index 960ed1f7..bd222942 100644 --- a/app/tests/test_cleanup.py +++ b/app/tests/test_cleanup.py @@ -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 diff --git a/app/tests/test_crop.py b/app/tests/test_crop.py index 46aeccfd..0088d5cc 100644 --- a/app/tests/test_crop.py +++ b/app/tests/test_crop.py @@ -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 diff --git a/app/tests/test_external_auth.py b/app/tests/test_external_auth.py index 1056bf17..6c1fdf14 100644 --- a/app/tests/test_external_auth.py +++ b/app/tests/test_external_auth.py @@ -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 diff --git a/app/tests/test_login.py b/app/tests/test_login.py index 371e3bcf..382c901a 100644 --- a/app/tests/test_login.py +++ b/app/tests/test_login.py @@ -1,4 +1,3 @@ -import os from django.test import Client from webodm import settings from .classes import BootTestCase diff --git a/app/tests/test_quota.py b/app/tests/test_quota.py index 4bc20521..076b45cc 100644 --- a/app/tests/test_quota.py +++ b/app/tests/test_quota.py @@ -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 diff --git a/app/tests/test_settings.py b/app/tests/test_settings.py index f784988f..b643c28a 100644 --- a/app/tests/test_settings.py +++ b/app/tests/test_settings.py @@ -1,5 +1,4 @@ import os -import time from django.core.exceptions import ValidationError from django.core.files import File diff --git a/app/tests/test_theme.py b/app/tests/test_theme.py index 4e2c02ce..7cdf7a4b 100644 --- a/app/tests/test_theme.py +++ b/app/tests/test_theme.py @@ -1,7 +1,4 @@ -import os -import re -from django.contrib.staticfiles import finders from django.test import Client from .classes import BootTestCase diff --git a/app/views/app.py b/app/views/app.py index e67739eb..672b83e3 100644 --- a/app/views/app.py +++ b/app/views/app.py @@ -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 diff --git a/app/views/dev.py b/app/views/dev.py index 90e8f1d4..824b4758 100644 --- a/app/views/dev.py +++ b/app/views/dev.py @@ -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') diff --git a/app/views/public.py b/app/views/public.py index 252ab1d3..dbd3ffab 100644 --- a/app/views/public.py +++ b/app/views/public.py @@ -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 diff --git a/coreplugins/cesiumion/api_views.py b/coreplugins/cesiumion/api_views.py index a647eaf6..29513c75 100644 --- a/coreplugins/cesiumion/api_views.py +++ b/coreplugins/cesiumion/api_views.py @@ -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"]) diff --git a/coreplugins/cesiumion/app_views.py b/coreplugins/cesiumion/app_views.py index 85c80e2b..ecd681a5 100644 --- a/coreplugins/cesiumion/app_views.py +++ b/coreplugins/cesiumion/app_views.py @@ -1,5 +1,4 @@ import json -import requests from django import forms from django.contrib import messages diff --git a/coreplugins/cesiumion/plugin.py b/coreplugins/cesiumion/plugin.py index 9090d161..b3b2b4f2 100644 --- a/coreplugins/cesiumion/plugin.py +++ b/coreplugins/cesiumion/plugin.py @@ -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 diff --git a/coreplugins/cesiumion/uploader.py b/coreplugins/cesiumion/uploader.py index d437b8d8..453c386a 100644 --- a/coreplugins/cesiumion/uploader.py +++ b/coreplugins/cesiumion/uploader.py @@ -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: diff --git a/coreplugins/cloudimport/api_views.py b/coreplugins/cloudimport/api_views.py index 46969104..ac8fa3e9 100644 --- a/coreplugins/cloudimport/api_views.py +++ b/coreplugins/cloudimport/api_views.py @@ -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 diff --git a/coreplugins/cloudimport/app_views.py b/coreplugins/cloudimport/app_views.py index 9bffe831..447407b4 100644 --- a/coreplugins/cloudimport/app_views.py +++ b/coreplugins/cloudimport/app_views.py @@ -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 diff --git a/coreplugins/cloudimport/platform_extension.py b/coreplugins/cloudimport/platform_extension.py index cfb5332a..d6676e78 100644 --- a/coreplugins/cloudimport/platform_extension.py +++ b/coreplugins/cloudimport/platform_extension.py @@ -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): diff --git a/coreplugins/cloudimport/platforms/github.py b/coreplugins/cloudimport/platforms/github.py index 96968d95..74f45f5e 100644 --- a/coreplugins/cloudimport/platforms/github.py +++ b/coreplugins/cloudimport/platforms/github.py @@ -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): diff --git a/coreplugins/cloudimport/platforms/piwigo.py b/coreplugins/cloudimport/platforms/piwigo.py index 346c33c2..0f666995 100644 --- a/coreplugins/cloudimport/platforms/piwigo.py +++ b/coreplugins/cloudimport/platforms/piwigo.py @@ -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')] diff --git a/coreplugins/cloudimport/plugin.py b/coreplugins/cloudimport/plugin.py index 1e19eba5..ddcf19c8 100644 --- a/coreplugins/cloudimport/plugin.py +++ b/coreplugins/cloudimport/plugin.py @@ -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 diff --git a/coreplugins/contours/api.py b/coreplugins/contours/api.py index 3a72c151..32369214 100644 --- a/coreplugins/contours/api.py +++ b/coreplugins/contours/api.py @@ -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)) diff --git a/coreplugins/diagnostic/plugin.py b/coreplugins/diagnostic/plugin.py index bc606890..3382b3ab 100644 --- a/coreplugins/diagnostic/plugin.py +++ b/coreplugins/diagnostic/plugin.py @@ -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(): """ diff --git a/coreplugins/dronedb/api_views.py b/coreplugins/dronedb/api_views.py index 73378902..13bd692c 100644 --- a/coreplugins/dronedb/api_views.py +++ b/coreplugins/dronedb/api_views.py @@ -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) diff --git a/coreplugins/dronedb/app_views.py b/coreplugins/dronedb/app_views.py index f32841ed..d9c78fef 100644 --- a/coreplugins/dronedb/app_views.py +++ b/coreplugins/dronedb/app_views.py @@ -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): diff --git a/coreplugins/dronedb/ddb.py b/coreplugins/dronedb/ddb.py index 1d99d15d..ad02589b 100644 --- a/coreplugins/dronedb/ddb.py +++ b/coreplugins/dronedb/ddb.py @@ -1,6 +1,4 @@ -from functools import reduce import requests -from os import path from app.plugins import logger from urllib.parse import urlparse diff --git a/coreplugins/dronedb/plugin.py b/coreplugins/dronedb/plugin.py index 49eddb0f..e1fa6028 100644 --- a/coreplugins/dronedb/plugin.py +++ b/coreplugins/dronedb/plugin.py @@ -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 diff --git a/coreplugins/editshortlinks/api.py b/coreplugins/editshortlinks/api.py index 120b43bf..62e5f2a8 100644 --- a/coreplugins/editshortlinks/api.py +++ b/coreplugins/editshortlinks/api.py @@ -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 diff --git a/coreplugins/editshortlinks/plugin.py b/coreplugins/editshortlinks/plugin.py index e6418a0f..c3dde1a2 100644 --- a/coreplugins/editshortlinks/plugin.py +++ b/coreplugins/editshortlinks/plugin.py @@ -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): diff --git a/coreplugins/lightning/plugin.py b/coreplugins/lightning/plugin.py index 4a7597c2..60fe846a 100644 --- a/coreplugins/lightning/plugin.py +++ b/coreplugins/lightning/plugin.py @@ -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 diff --git a/coreplugins/measure/api.py b/coreplugins/measure/api.py index 6220171a..a0af8685 100644 --- a/coreplugins/measure/api.py +++ b/coreplugins/measure/api.py @@ -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 _ diff --git a/coreplugins/measure/volume.py b/coreplugins/measure/volume.py index 2fc78bdc..c0c72197 100644 --- a/coreplugins/measure/volume.py +++ b/coreplugins/measure/volume.py @@ -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 diff --git a/coreplugins/objdetect/api.py b/coreplugins/objdetect/api.py index 3bf8c92f..dc71549d 100644 --- a/coreplugins/objdetect/api.py +++ b/coreplugins/objdetect/api.py @@ -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] diff --git a/coreplugins/openaerialmap/api.py b/coreplugins/openaerialmap/api.py index 2b640e6a..d74b16cf 100644 --- a/coreplugins/openaerialmap/api.py +++ b/coreplugins/openaerialmap/api.py @@ -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 diff --git a/coreplugins/osm-quickedit/plugin.py b/coreplugins/osm-quickedit/plugin.py index dac4e254..a490c40d 100644 --- a/coreplugins/osm-quickedit/plugin.py +++ b/coreplugins/osm-quickedit/plugin.py @@ -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): diff --git a/coreplugins/shortlinks/api.py b/coreplugins/shortlinks/api.py index f35b6a7a..2836a74b 100644 --- a/coreplugins/shortlinks/api.py +++ b/coreplugins/shortlinks/api.py @@ -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 diff --git a/coreplugins/shortlinks/plugin.py b/coreplugins/shortlinks/plugin.py index 54f8a60c..5de79f87 100644 --- a/coreplugins/shortlinks/plugin.py +++ b/coreplugins/shortlinks/plugin.py @@ -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): diff --git a/coreplugins/tasknotification/plugin.py b/coreplugins/tasknotification/plugin.py index 715d82f8..9b76dced 100644 --- a/coreplugins/tasknotification/plugin.py +++ b/coreplugins/tasknotification/plugin.py @@ -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}') diff --git a/coreplugins/tasknotification/signals.py b/coreplugins/tasknotification/signals.py index 18236775..6b91c8fc 100644 --- a/coreplugins/tasknotification/signals.py +++ b/coreplugins/tasknotification/signals.py @@ -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 diff --git a/docker-compose.yml.bacalhau b/docker-compose.yml.bacalhau new file mode 100644 index 00000000..7c133bfa --- /dev/null +++ b/docker-compose.yml.bacalhau @@ -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 diff --git a/nodeodm/tests.py b/nodeodm/tests.py index 6a538409..7ce2cc90 100644 --- a/nodeodm/tests.py +++ b/nodeodm/tests.py @@ -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 diff --git a/nodeodm/views.py b/nodeodm/views.py index 91ea44a2..b8e4ee02 100644 --- a/nodeodm/views.py +++ b/nodeodm/views.py @@ -1,3 +1,2 @@ -from django.shortcuts import render # Create your views here. diff --git a/slate/examples/process_images.py b/slate/examples/process_images.py index d4181886..56b8c53d 100644 --- a/slate/examples/process_images.py +++ b/slate/examples/process_images.py @@ -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: diff --git a/webodm/settings.py b/webodm/settings.py index 5b4e3fdf..e257bb95 100644 --- a/webodm/settings.py +++ b/webodm/settings.py @@ -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