diff --git a/app/models/task.py b/app/models/task.py index 071d6359..aace4569 100644 --- a/app/models/task.py +++ b/app/models/task.py @@ -226,9 +226,14 @@ class Task(models.Model): """ Get a path relative to the place where assets are stored """ + return self.task_path("assets", *args) + + def task_path(self, *args): + """ + Get path relative to the root task directory + """ return os.path.join(settings.MEDIA_ROOT, assets_directory_path(self.id, self.project.id, ""), - "assets", *args) def is_asset_available_slow(self, asset): diff --git a/app/tests/test_api_task.py b/app/tests/test_api_task.py index 60dab5ee..053a5d75 100644 --- a/app/tests/test_api_task.py +++ b/app/tests/test_api_task.py @@ -7,6 +7,7 @@ from datetime import timedelta 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 @@ -67,6 +68,8 @@ class TestApiTask(BootTransactionTestCase): image1 = open("app/fixtures/tiny_drone_image.jpg", 'rb') image2 = open("app/fixtures/tiny_drone_image_2.jpg", 'rb') + img1 = Image.open("app/fixtures/tiny_drone_image.jpg") + # Not authenticated? res = client.post("/api/projects/{}/tasks/".format(project.id), { 'images': [image1, image2] @@ -110,6 +113,27 @@ class TestApiTask(BootTransactionTestCase): self.assertTrue(multiple_param_task.name == 'test_task') self.assertTrue(multiple_param_task.processing_node.id == pnode.id) + # Uploaded images should be the same size as originals + with Image.open(multiple_param_task.task_path("tiny_drone_image.jpg")) as im: + self.assertTrue(im.size == img1.size) + + # Normal case with images[], GCP, name and processing node parameter and resize_to option + res = client.post("/api/projects/{}/tasks/".format(project.id), { + 'images': [image1, image2], + 'name': 'test_task', + 'processing_node': pnode.id, + 'resize_to': img1.size[0] / 2.0 + }, format="multipart") + self.assertTrue(res.status_code == status.HTTP_201_CREATED) + resized_task = Task.objects.latest('created_at') + + # Uploaded images should have been resized + with Image.open(resized_task.task_path("tiny_drone_image.jpg")) as im: + self.assertTrue(im.size[0] == img1.size[0] / 2.0) + + # TODO: gcp entries should have been resized + + # Cannot create a task with images[], name, but invalid processing node parameter res = client.post("/api/projects/{}/tasks/".format(project.id), { 'images': [image1, image2], diff --git a/nginx/letsencrypt-autogen.sh b/nginx/letsencrypt-autogen.sh index c6cc1885..fa7ac9df 100755 --- a/nginx/letsencrypt-autogen.sh +++ b/nginx/letsencrypt-autogen.sh @@ -28,7 +28,7 @@ if [ $? -eq 0 ]; then fi # Generate/update certificate -certbot certonly --tls-sni-01-port 8000 --work-dir ./letsencrypt --config-dir ./letsencrypt --logs-dir ./letsencrypt --standalone -d $DOMAIN --register-unsafely-without-email --agree-tos --keep +certbot certonly --tls-sni-01-port 8000 --http-01-port 8080 --work-dir ./letsencrypt --config-dir ./letsencrypt --logs-dir ./letsencrypt --standalone -d $DOMAIN --register-unsafely-without-email --agree-tos --keep # Create ssl dir if necessary if [ ! -e ssl/ ]; then diff --git a/service/webodm-gunicorn.service b/service/webodm-gunicorn.service index 83151950..036be01e 100644 --- a/service/webodm-gunicorn.service +++ b/service/webodm-gunicorn.service @@ -8,7 +8,7 @@ User=odm Group=odm PIDFile=/run/webodm-gunicorn.pid WorkingDirectory=/webodm -ExecStart=/webodm/python3-venv/bin/gunicorn webodm.wsgi --bind unix:/tmp/gunicorn.sock --timeout 360 --preload +ExecStart=/webodm/python3-venv/bin/gunicorn webodm.wsgi --bind unix:/tmp/gunicorn.sock --timeout 300000 --max-requests 250 --preload ExecStop=/bin/kill -s QUIT $MAINPID Restart=on-failure