Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
retries = 0
while True:
try:
task_info = api.get_task(uuid).info()
if task_info.status.value == status:
return True
except (NodeResponseError, NodeServerError):
pass
time.sleep(0.5)
retries += 1
if retries >= num_retries:
self.assertTrue(False, error_description)
return False
api = Node("localhost", 11224, "test_token")
online_node = ProcessingNode.objects.get(pk=3)
self.assertTrue(online_node.update_node_info(), "Could update info")
# Cannot call info(), options() without tokens
api.token = "invalid"
self.assertRaises(NodeResponseError, api.info)
self.assertRaises(NodeResponseError, api.options)
# Cannot call create_task() without token
import glob
self.assertRaises(NodeResponseError, api.create_task, glob.glob("nodeodm/fixtures/test_images/*.JPG"))
# Can call create_task() with token
api.token = "test_token"
res = api.create_task(
def setUp(self):
self.api_client = Node("localhost", 11223)
retries = 0
while True:
try:
task_info = api.get_task(uuid).info()
if task_info.status.value == status:
return True
except (NodeServerError, NodeResponseError):
pass
time.sleep(0.5)
retries += 1
if retries >= num_retries:
self.assertTrue(False, error_description)
return False
api = Node("localhost", 11223)
online_node = ProcessingNode.objects.get(pk=1)
# Can call info(), options()
self.assertTrue(type(api.info().version) == str)
self.assertTrue(len(api.options()) > 0)
# Can call new_task()
import glob
res = api.create_task(
glob.glob("nodeodm/fixtures/test_images/*.JPG"),
{'force-ccd': 6.16},
"test")
uuid = res.uuid
self.assertTrue(uuid != None)
# Can call task_info()
def test_offline_api(self):
api = Node("offline-host", 3000)
self.assertRaises(NodeConnectionError, api.info)
self.assertRaises(NodeConnectionError, api.options)
self.assertTrue(online_node.cancel_task(uuid))
self.assertRaises(NodeResponseError, online_node.cancel_task, "wrong-uuid")
# Wait for task to be canceled
wait_for_status(api, uuid, status_codes.CANCELED, 5, "Could not remove task")
self.assertTrue(online_node.remove_task(uuid))
self.assertRaises(NodeResponseError, online_node.remove_task, "wrong-uuid")
# Cannot delete task again
self.assertRaises(NodeResponseError, online_node.remove_task, uuid)
# Task has been deleted
self.assertRaises(NodeResponseError, online_node.get_task_info, uuid)
# Test URL building for HTTPS
sslApi = Node("localhost", 443, 'abc')
self.assertEqual(sslApi.url('/info'), 'https://localhost/info?token=abc')
def api_client(self, timeout=30):
return Node(self.hostname, self.port, self.token, timeout)
import os
import sys
sys.path.append('..')
from pyodm import Node, exceptions
node = Node("localhost", 3000)
try:
# Start a task
print("Uploading images...")
task = node.create_task(['images/image_1.jpg', 'images/image_2.jpg'],
{'dsm': True, 'orthophoto-resolution': 4})
print(task.info())
try:
# This will block until the task is finished
# or will raise an exception
task.wait_for_completion()
print("Task completed, downloading results...")
# Retrieve results