kopia lustrzana https://github.com/OpenDroneMap/WebODM
Ruff; 'unsafe fixes' - manually validated.
rodzic
8f1cb4f30f
commit
e3c26130bb
|
@ -176,7 +176,7 @@ def get_plugins():
|
||||||
"""
|
"""
|
||||||
# Cache plugins search
|
# Cache plugins search
|
||||||
global plugins
|
global plugins
|
||||||
if plugins != None: return plugins
|
if plugins is not None: return plugins
|
||||||
|
|
||||||
plugins_paths = get_plugins_paths()
|
plugins_paths = get_plugins_paths()
|
||||||
plugins = []
|
plugins = []
|
||||||
|
|
|
@ -88,7 +88,6 @@ def export_raster(input, output, **opts):
|
||||||
# Output format
|
# Output format
|
||||||
driver = "GTiff"
|
driver = "GTiff"
|
||||||
compress = None
|
compress = None
|
||||||
max_bands = 9999
|
|
||||||
with_alpha = True
|
with_alpha = True
|
||||||
rgb = False
|
rgb = False
|
||||||
indexes = src.indexes
|
indexes = src.indexes
|
||||||
|
|
|
@ -500,7 +500,7 @@ class TestApi(BootTestCase):
|
||||||
def test_token_auth(self):
|
def test_token_auth(self):
|
||||||
client = APIClient()
|
client = APIClient()
|
||||||
|
|
||||||
pnode = ProcessingNode.objects.create(
|
ProcessingNode.objects.create(
|
||||||
hostname="localhost",
|
hostname="localhost",
|
||||||
port=999
|
port=999
|
||||||
)
|
)
|
||||||
|
|
|
@ -44,7 +44,7 @@ class TestApiTask(BootTransactionTestCase):
|
||||||
owner=user,
|
owner=user,
|
||||||
name="test project"
|
name="test project"
|
||||||
)
|
)
|
||||||
other_project = Project.objects.create(
|
Project.objects.create(
|
||||||
owner=other_user,
|
owner=other_user,
|
||||||
name="another test project"
|
name="another test project"
|
||||||
)
|
)
|
||||||
|
|
|
@ -269,7 +269,6 @@ class TestApiTask(BootTransactionTestCase):
|
||||||
self.assertEqual(task.status, status_codes.COMPLETED)
|
self.assertEqual(task.status, status_codes.COMPLETED)
|
||||||
|
|
||||||
# Download task backup
|
# Download task backup
|
||||||
task_uuid = task.uuid
|
|
||||||
res = client.get("/api/projects/{}/tasks/{}/backup".format(project.id, task.id))
|
res = client.get("/api/projects/{}/tasks/{}/backup".format(project.id, task.id))
|
||||||
self.assertEqual(res.status_code, status.HTTP_200_OK)
|
self.assertEqual(res.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class TestApiUsers(BootTestCase):
|
||||||
def test_users(self):
|
def test_users(self):
|
||||||
client = APIClient()
|
client = APIClient()
|
||||||
|
|
||||||
user = User.objects.get(username="testuser")
|
User.objects.get(username="testuser")
|
||||||
|
|
||||||
# Cannot list users (anonymous)
|
# Cannot list users (anonymous)
|
||||||
res = client.get("/api/users/?limit=30")
|
res = client.get("/api/users/?limit=30")
|
||||||
|
|
|
@ -19,7 +19,7 @@ class TestSettings(BootTestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_settings(self):
|
def test_settings(self):
|
||||||
c = Client()
|
Client()
|
||||||
|
|
||||||
# There should always be a Setting object
|
# There should always be a Setting object
|
||||||
self.assertTrue(Setting.objects.count() == 1, "There's a settings object")
|
self.assertTrue(Setting.objects.count() == 1, "There's a settings object")
|
||||||
|
|
|
@ -19,7 +19,8 @@ from .globals import PROJECT_NAME, ION_API_URL
|
||||||
from .uploader import upload_to_ion
|
from .uploader import upload_to_ion
|
||||||
|
|
||||||
|
|
||||||
pluck = lambda dic, *keys: [dic[k] if k in dic else None for k in keys]
|
def pluck(dic, *keys):
|
||||||
|
return [dic[k] if k in dic else None for k in keys]
|
||||||
|
|
||||||
|
|
||||||
### ###
|
### ###
|
||||||
|
@ -193,7 +194,7 @@ class ShareTaskView(TaskView):
|
||||||
asset_type = FILE_TO_ASSET[file_name]
|
asset_type = FILE_TO_ASSET[file_name]
|
||||||
|
|
||||||
asset_info = get_asset_info(task.id, asset_type)
|
asset_info = get_asset_info(task.id, asset_type)
|
||||||
ion_id = asset_info["id"]
|
asset_info["id"]
|
||||||
is_error = len(asset_info["error"]) > 0
|
is_error = len(asset_info["error"]) > 0
|
||||||
is_task = is_asset_task(asset_info)
|
is_task = is_asset_task(asset_info)
|
||||||
is_exported = asset_info["id"] is not None and not is_task
|
is_exported = asset_info["id"] is not None and not is_task
|
||||||
|
|
|
@ -209,7 +209,7 @@ def upload_to_ion(
|
||||||
asset_info["error"] = str(e)
|
asset_info["error"] = str(e)
|
||||||
asset_logger.error(e)
|
asset_logger.error(e)
|
||||||
|
|
||||||
if del_directory != None:
|
if del_directory is not None:
|
||||||
rmtree(del_directory)
|
rmtree(del_directory)
|
||||||
|
|
||||||
set_asset_info(task_id, asset_type, asset_info)
|
set_asset_info(task_id, asset_type, asset_info)
|
|
@ -19,18 +19,18 @@ class ImportFolderTaskView(TaskView):
|
||||||
platform_name = request.data.get('platform', None)
|
platform_name = request.data.get('platform', None)
|
||||||
|
|
||||||
# Make sure both values are set
|
# Make sure both values are set
|
||||||
if folder_url == None or platform_name == None:
|
if folder_url is None or platform_name is None:
|
||||||
return Response({'error': 'Folder URL and platform name must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': 'Folder URL and platform name must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
# Fetch the platform by name
|
# Fetch the platform by name
|
||||||
platform = get_platform_by_name(platform_name)
|
platform = get_platform_by_name(platform_name)
|
||||||
|
|
||||||
# Make sure that the platform actually exists
|
# Make sure that the platform actually exists
|
||||||
if platform == None:
|
if platform is None:
|
||||||
return Response({'error': 'Failed to find a platform with the name \'{}\''.format(platform_name)}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': 'Failed to find a platform with the name \'{}\''.format(platform_name)}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
# Verify that the folder url is valid
|
# Verify that the folder url is valid
|
||||||
if platform.verify_folder_url(folder_url) == None:
|
if platform.verify_folder_url(folder_url) is None:
|
||||||
return Response({'error': 'Invalid URL'}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': 'Invalid URL'}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
# Get the files from the folder
|
# Get the files from the folder
|
||||||
|
@ -62,7 +62,7 @@ class CheckUrlTaskView(TaskView):
|
||||||
combined_id = "{}_{}".format(project_pk, pk)
|
combined_id = "{}_{}".format(project_pk, pk)
|
||||||
folder_url = get_current_plugin().get_global_data_store().get_string(combined_id, default = None)
|
folder_url = get_current_plugin().get_global_data_store().get_string(combined_id, default = None)
|
||||||
|
|
||||||
if folder_url == None:
|
if folder_url is None:
|
||||||
return Response({}, status=status.HTTP_200_OK)
|
return Response({}, status=status.HTTP_200_OK)
|
||||||
else:
|
else:
|
||||||
return Response({'folder_url': folder_url}, status=status.HTTP_200_OK)
|
return Response({'folder_url': folder_url}, status=status.HTTP_200_OK)
|
||||||
|
@ -76,12 +76,12 @@ class PlatformsVerifyTaskView(TaskView):
|
||||||
platform = get_platform_by_name(platform_name)
|
platform = get_platform_by_name(platform_name)
|
||||||
|
|
||||||
# Make sure that the platform actually exists
|
# Make sure that the platform actually exists
|
||||||
if platform == None:
|
if platform is None:
|
||||||
return Response({'error': 'Failed to find a platform with the name \'{}\''.format(platform_name)}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': 'Failed to find a platform with the name \'{}\''.format(platform_name)}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
# Verify that the folder url is valid
|
# Verify that the folder url is valid
|
||||||
folder = platform.verify_folder_url(folder_url)
|
folder = platform.verify_folder_url(folder_url)
|
||||||
if folder == None:
|
if folder is None:
|
||||||
return Response({'error': 'Invalid URL'}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': 'Invalid URL'}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
# Return the folder
|
# Return the folder
|
||||||
|
|
|
@ -31,7 +31,7 @@ class CloudPlatform(ABC):
|
||||||
|
|
||||||
def import_from_folder(self, folder_url):
|
def import_from_folder(self, folder_url):
|
||||||
# Verify the url
|
# Verify the url
|
||||||
if self.verify_folder_url(folder_url) == None:
|
if self.verify_folder_url(folder_url) is None:
|
||||||
raise Exception('Invalid URL')
|
raise Exception('Invalid URL')
|
||||||
|
|
||||||
# Parse the url and get all necessary information
|
# Parse the url and get all necessary information
|
||||||
|
|
|
@ -23,7 +23,7 @@ class CloudLibrary(PlatformExtension):
|
||||||
|
|
||||||
def serialize(self, **kwargs):
|
def serialize(self, **kwargs):
|
||||||
base_payload = {'name': self.name, 'folder_url_example': self.folder_url_example}
|
base_payload = {'name': self.name, 'folder_url_example': self.folder_url_example}
|
||||||
if kwargs['user'] != None:
|
if kwargs['user'] is not None:
|
||||||
ds = get_current_plugin().get_user_data_store(kwargs['user'])
|
ds = get_current_plugin().get_user_data_store(kwargs['user'])
|
||||||
server_url_field = self.get_server_url_field()
|
server_url_field = self.get_server_url_field()
|
||||||
stored_value = server_url_field.get_stored_value(ds)
|
stored_value = server_url_field.get_stored_value(ds)
|
||||||
|
@ -102,7 +102,7 @@ class GetAllFoldersTaskView(TaskView):
|
||||||
def get(self, request, platform_name):
|
def get(self, request, platform_name):
|
||||||
platform = get_platform_by_name(platform_name)
|
platform = get_platform_by_name(platform_name)
|
||||||
|
|
||||||
if platform == None:
|
if platform is None:
|
||||||
return Response({'error': 'Failed to find a platform with the name \'{}\''.format(platform_name)}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': 'Failed to find a platform with the name \'{}\''.format(platform_name)}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
ds = get_current_plugin().get_user_data_store(request.user)
|
ds = get_current_plugin().get_user_data_store(request.user)
|
||||||
|
|
|
@ -7,7 +7,7 @@ platforms = None
|
||||||
def get_all_platforms():
|
def get_all_platforms():
|
||||||
# Cache platforms search
|
# Cache platforms search
|
||||||
global platforms
|
global platforms
|
||||||
if platforms == None:
|
if platforms is None:
|
||||||
platforms = read_platform_from_files()
|
platforms = read_platform_from_files()
|
||||||
return platforms
|
return platforms
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ def update_token(request, token):
|
||||||
def get_ddb(request):
|
def get_ddb(request):
|
||||||
registry_url, username, password, token = get_settings(request)
|
registry_url, username, password, token = get_settings(request)
|
||||||
|
|
||||||
if registry_url == None or username == None or password == None:
|
if registry_url is None or username is None or password is None:
|
||||||
raise ValueError('Credentials must be set.')
|
raise ValueError('Credentials must be set.')
|
||||||
|
|
||||||
return DroneDB(registry_url, username, password, token, lambda token: update_token(request, token))
|
return DroneDB(registry_url, username, password, token, lambda token: update_token(request, token))
|
||||||
|
@ -60,7 +60,7 @@ class CheckCredentialsTaskView(TaskView):
|
||||||
password = request.data.get('password', None)
|
password = request.data.get('password', None)
|
||||||
|
|
||||||
# Make sure both values are set
|
# Make sure both values are set
|
||||||
if hub_url == None or username == None or password == None:
|
if hub_url is None or username is None or password is None:
|
||||||
return Response({'error': 'All fields must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': 'All fields must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -90,7 +90,7 @@ class OrganizationsTaskView(TaskView):
|
||||||
class DatasetsTaskView(TaskView):
|
class DatasetsTaskView(TaskView):
|
||||||
def get(self, request, org=None):
|
def get(self, request, org=None):
|
||||||
|
|
||||||
if org == None:
|
if org is None:
|
||||||
return Response({'error': 'Organization must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': 'Organization must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -107,7 +107,7 @@ class DatasetsTaskView(TaskView):
|
||||||
class FoldersTaskView(TaskView):
|
class FoldersTaskView(TaskView):
|
||||||
def get(self, request, org=None, ds=None):
|
def get(self, request, org=None, ds=None):
|
||||||
|
|
||||||
if org == None or ds == None:
|
if org is None or ds is None:
|
||||||
return Response({'error': 'Organization and dataset must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': 'Organization and dataset must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -127,7 +127,7 @@ class VerifyUrlTaskView(TaskView):
|
||||||
# Read form data
|
# Read form data
|
||||||
url = request.data.get('url', None)
|
url = request.data.get('url', None)
|
||||||
|
|
||||||
if url == None:
|
if url is None:
|
||||||
return Response({'error': 'Url must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': 'Url must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
_, username, password, _ = get_settings(request)
|
_, username, password, _ = get_settings(request)
|
||||||
|
@ -161,7 +161,7 @@ class ImportDatasetTaskView(TaskView):
|
||||||
# Read form data
|
# Read form data
|
||||||
ddb_url = request.data.get('ddb_url', None)
|
ddb_url = request.data.get('ddb_url', None)
|
||||||
|
|
||||||
if ddb_url == None:
|
if ddb_url is None:
|
||||||
return Response({'error': 'DroneDB url must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'error': 'DroneDB url must be set.'}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
registry_url, orgSlug, dsSlug, folder = parse_url(ddb_url).values()
|
registry_url, orgSlug, dsSlug, folder = parse_url(ddb_url).values()
|
||||||
|
@ -208,7 +208,7 @@ def import_files(task_id, carrier):
|
||||||
|
|
||||||
headers = {}
|
headers = {}
|
||||||
|
|
||||||
if carrier['token'] != None:
|
if carrier['token'] is not None:
|
||||||
headers['Authorization'] = 'Bearer ' + carrier['token']
|
headers['Authorization'] = 'Bearer ' + carrier['token']
|
||||||
|
|
||||||
def download_file(task, file):
|
def download_file(task, file):
|
||||||
|
@ -252,7 +252,7 @@ class CheckUrlTaskView(TaskView):
|
||||||
combined_id = "{}_{}".format(project_pk, pk)
|
combined_id = "{}_{}".format(project_pk, pk)
|
||||||
data = get_current_plugin().get_global_data_store().get_json(combined_id, default = None)
|
data = get_current_plugin().get_global_data_store().get_json(combined_id, default = None)
|
||||||
|
|
||||||
if data == None or 'ddbWebUrl' not in data:
|
if data is None or 'ddbWebUrl' not in data:
|
||||||
return Response({'ddbWebUrl': None}, status=status.HTTP_200_OK)
|
return Response({'ddbWebUrl': None}, status=status.HTTP_200_OK)
|
||||||
else:
|
else:
|
||||||
return Response({'ddbUrl': data['ddbWebUrl']}, status=status.HTTP_200_OK)
|
return Response({'ddbUrl': data['ddbWebUrl']}, status=status.HTTP_200_OK)
|
||||||
|
@ -282,7 +282,7 @@ def ddb_cleanup(sender, task_id, **kwargs):
|
||||||
class StatusTaskView(TaskView):
|
class StatusTaskView(TaskView):
|
||||||
def get(self, request, pk):
|
def get(self, request, pk):
|
||||||
|
|
||||||
task = self.get_and_check_task(request, pk)
|
self.get_and_check_task(request, pk)
|
||||||
|
|
||||||
# Associate the folder url with the project and task
|
# Associate the folder url with the project and task
|
||||||
status_key = get_status_key(pk)
|
status_key = get_status_key(pk)
|
||||||
|
|
|
@ -72,7 +72,8 @@ def calc_volume(input_dem, pts=None, pts_epsg=None, geojson_polygon=None, decima
|
||||||
x_grid, y_grid = np.meshgrid(np.linspace(0, w - 1, w), np.linspace(0, h - 1, h))
|
x_grid, y_grid = np.meshgrid(np.linspace(0, w - 1, w), np.linspace(0, h - 1, h))
|
||||||
|
|
||||||
# Perform curve fitting
|
# Perform curve fitting
|
||||||
linear_func = lambda xy, m1, m2, b: m1 * xy[0] + m2 * xy[1] + b
|
def linear_func(xy, m1, m2, b):
|
||||||
|
return m1 * xy[0] + m2 * xy[1] + b
|
||||||
params, covariance = curve_fit(linear_func, np.vstack((xs, ys)), zs)
|
params, covariance = curve_fit(linear_func, np.vstack((xs, ys)), zs)
|
||||||
|
|
||||||
base = linear_func((x_grid, y_grid), *params)
|
base = linear_func((x_grid, y_grid), *params)
|
||||||
|
|
|
@ -17,7 +17,7 @@ def send(subject : str, message : str, smtp_config : dict = None):
|
||||||
timeout=10
|
timeout=10
|
||||||
)
|
)
|
||||||
|
|
||||||
result = send_mail(
|
send_mail(
|
||||||
subject,
|
subject,
|
||||||
message,
|
message,
|
||||||
smtp_config.get('smtp_from_address'),
|
smtp_config.get('smtp_from_address'),
|
||||||
|
|
|
@ -75,7 +75,8 @@ def hours_minutes_secs(milliseconds):
|
||||||
h = milliseconds // ch
|
h = milliseconds // ch
|
||||||
m = (milliseconds - h * ch) // cm
|
m = (milliseconds - h * ch) // cm
|
||||||
s = round((milliseconds - h * ch - m * cm) / 1000)
|
s = round((milliseconds - h * ch - m * cm) / 1000)
|
||||||
pad = lambda n: '0' + str(n) if n < 10 else str(n)
|
def pad(n):
|
||||||
|
return '0' + str(n) if n < 10 else str(n)
|
||||||
|
|
||||||
if s == 60:
|
if s == 60:
|
||||||
m += 1
|
m += 1
|
||||||
|
|
Ładowanie…
Reference in New Issue