From e79de9490ddaeec3c142ca8cb5e2effc0cca7192 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 16 Jan 2019 14:51:57 -0500 Subject: [PATCH] Updated README, fixed unit tests --- README.md | 24 ++++++++++++++++++++++++ app/models/task.py | 14 ++++++++------ app/tests/test_api_task.py | 17 ++++++++++++++--- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e30ad513..d39e9299 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ A free, user-friendly, extendable application and [API](http://docs.webodm.org) * [Backup and Restore](#backup-and-restore) * [Reset Password](#reset-password) * [Manage Plugins](#manage-plugins) + * [Update](#update) * [Customizing and Extending](#customizing-and-extending) * [API Docs](#api-docs) * [ODM, NodeODM, WebODM... what?](#odm-nodeodm-webodm-what) @@ -134,6 +135,7 @@ On Windows, docker-compose fails with `Failed to execute the script docker-compo Cannot access WebODM using Microsoft Edge on Windows 10 | Try to tweak your internet properties according to [these instructions](http://www.hanselman.com/blog/FixedMicrosoftEdgeCantSeeOrOpenVirtualBoxhostedLocalWebSites.aspx) Getting a `No space left on device` error, but hard drive has enough space left | Docker on Windows by default will allocate only 20GB of space to the default docker-machine. You need to increase that amount. See [this link](http://support.divio.com/local-development/docker/managing-disk-space-in-your-docker-vm) and [this link](https://www.howtogeek.com/124622/how-to-enlarge-a-virtual-machines-disk-in-virtualbox-or-vmware/) Cannot start WebODM via `./webodm.sh start`, error messages are different at each retry | You could be running out of memory. Make sure you have enough RAM available. 2GB should be the recommended minimum, unless you know what you are doing +While running WebODM with Docker Toolbox (VirtualBox) you cannot access WebODM from another computer in the same network. | As Administrator, run `cmd.exe` and then type `"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "default" natpf1 "rule-name,tcp,,8000,,8000"` Have you had other issues? Please [report them](https://github.com/OpenDroneMap/WebODM/issues/new) so that we can include them in this document. @@ -187,6 +189,28 @@ To enable/disable a plugin type: On some platforms (eg. Windows), if you want to manage plugins, you will need to make sure that the `./plugins` directory can be mounted as a docker volume and then pass the `--mount-plugins-volume` flag to `webodm.sh`. Check the docker documentation. +### Update + +If you use docker, updating is as simple as running: + +```bash +./webodm.sh update +``` + +If you are running WebODM [natively](#run-it-natively), these commands should do it: + +```bash +cd /webodm +sudo su odm # Only in case you are running WebODM with a different user +git pull origin master +source python3-venv/bin/activate # If you are running a virtualenv +npm install +pip install -r requirements.txt +webpack --mode production +python manage.py collectstatic --noinput +python manage.py migrate +``` + ## Customizing and Extending Small customizations such as changing the application colors, name, logo, or addying custom CSS/HTML/Javascript can be performed directly from the Customize -- Brand/Theme panels within WebODM. No need to fork or change the code. diff --git a/app/models/task.py b/app/models/task.py index 0066acef..759f4a16 100644 --- a/app/models/task.py +++ b/app/models/task.py @@ -394,9 +394,14 @@ class Task(models.Model): last_update = 0 def callback(progress): nonlocal last_update - if time.time() - last_update >= 2 or (progress >= 1.0 - 1e-6 and progress <= 1.0 + 1e-6): - Task.objects.filter(pk=self.id).update(upload_progress=progress) + + time_has_elapsed = time.time() - last_update >= 2 + + if time_has_elapsed: self.check_if_canceled() + + if time_has_elapsed or (progress >= 1.0 - 1e-6 and progress <= 1.0 + 1e-6): + Task.objects.filter(pk=self.id).update(upload_progress=progress) last_update = time.time() # This takes a while @@ -744,10 +749,7 @@ class Task(models.Model): self.check_if_canceled() last_update = time.time() - with ThreadPoolExecutor(max_workers=cpu_count()) as executor: - resized_images = list(filter(lambda i: i is not None, executor.map( - partial(resize_image, resize_to=self.resize_to, done=callback), - images_path))) + resized_images = list(map(partial(resize_image, resize_to=self.resize_to, done=callback), images_path)) Task.objects.filter(pk=self.id).update(resize_progress=1.0) diff --git a/app/tests/test_api_task.py b/app/tests/test_api_task.py index 0e559893..376f89a0 100644 --- a/app/tests/test_api_task.py +++ b/app/tests/test_api_task.py @@ -14,6 +14,8 @@ from rest_framework.test import APIClient import worker from django.utils import timezone + +from app import pending_actions from app.models import Project, Task, ImageUpload from app.models.task import task_directory_path, full_task_directory_path, TaskInterruptedException from app.plugins.signals import task_completed, task_removed, task_removing @@ -401,14 +403,23 @@ class TestApiTask(BootTransactionTestCase): res = client.post("/api/projects/{}/tasks/{}/cancel/".format(project.id, task.id)) self.assertTrue(res.status_code == status.HTTP_200_OK) - # Should raise TaskInterruptedException - self.assertRaises(TaskInterruptedException, task.check_if_canceled) - # task is processed right away # Should have been canceled task.refresh_from_db() self.assertTrue(task.status == status_codes.CANCELED) + self.assertTrue(task.pending_action is None) + + # Manually set pending action + task.pending_action = pending_actions.CANCEL + task.save() + + # Should raise TaskInterruptedException + self.assertRaises(TaskInterruptedException, task.check_if_canceled) + + # Restore + task.pending_action = None + task.save() # Remove a task and verify that it calls the proper plugins signals with catch_signal(task_removing) as h1: