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
|
||||
global plugins
|
||||
if plugins != None: return plugins
|
||||
if plugins is not None: return plugins
|
||||
|
||||
plugins_paths = get_plugins_paths()
|
||||
plugins = []
|
||||
|
|
|
@ -88,7 +88,6 @@ def export_raster(input, output, **opts):
|
|||
# Output format
|
||||
driver = "GTiff"
|
||||
compress = None
|
||||
max_bands = 9999
|
||||
with_alpha = True
|
||||
rgb = False
|
||||
indexes = src.indexes
|
||||
|
|
|
@ -500,7 +500,7 @@ class TestApi(BootTestCase):
|
|||
def test_token_auth(self):
|
||||
client = APIClient()
|
||||
|
||||
pnode = ProcessingNode.objects.create(
|
||||
ProcessingNode.objects.create(
|
||||
hostname="localhost",
|
||||
port=999
|
||||
)
|
||||
|
|
|
@ -44,7 +44,7 @@ class TestApiTask(BootTransactionTestCase):
|
|||
owner=user,
|
||||
name="test project"
|
||||
)
|
||||
other_project = Project.objects.create(
|
||||
Project.objects.create(
|
||||
owner=other_user,
|
||||
name="another test project"
|
||||
)
|
||||
|
|
|
@ -269,7 +269,6 @@ class TestApiTask(BootTransactionTestCase):
|
|||
self.assertEqual(task.status, status_codes.COMPLETED)
|
||||
|
||||
# Download task backup
|
||||
task_uuid = task.uuid
|
||||
res = client.get("/api/projects/{}/tasks/{}/backup".format(project.id, task.id))
|
||||
self.assertEqual(res.status_code, status.HTTP_200_OK)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class TestApiUsers(BootTestCase):
|
|||
def test_users(self):
|
||||
client = APIClient()
|
||||
|
||||
user = User.objects.get(username="testuser")
|
||||
User.objects.get(username="testuser")
|
||||
|
||||
# Cannot list users (anonymous)
|
||||
res = client.get("/api/users/?limit=30")
|
||||
|
|
|
@ -19,7 +19,7 @@ class TestSettings(BootTestCase):
|
|||
pass
|
||||
|
||||
def test_settings(self):
|
||||
c = Client()
|
||||
Client()
|
||||
|
||||
# There should always be a Setting 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
|
||||
|
||||
|
||||
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_info = get_asset_info(task.id, asset_type)
|
||||
ion_id = asset_info["id"]
|
||||
asset_info["id"]
|
||||
is_error = len(asset_info["error"]) > 0
|
||||
is_task = is_asset_task(asset_info)
|
||||
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_logger.error(e)
|
||||
|
||||
if del_directory != None:
|
||||
if del_directory is not None:
|
||||
rmtree(del_directory)
|
||||
|
||||
set_asset_info(task_id, asset_type, asset_info)
|
|
@ -19,18 +19,18 @@ class ImportFolderTaskView(TaskView):
|
|||
platform_name = request.data.get('platform', None)
|
||||
|
||||
# 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)
|
||||
|
||||
# Fetch the platform by name
|
||||
platform = get_platform_by_name(platform_name)
|
||||
|
||||
# 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)
|
||||
|
||||
# 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)
|
||||
|
||||
# Get the files from the folder
|
||||
|
@ -62,7 +62,7 @@ class CheckUrlTaskView(TaskView):
|
|||
combined_id = "{}_{}".format(project_pk, pk)
|
||||
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)
|
||||
else:
|
||||
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)
|
||||
|
||||
# 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)
|
||||
|
||||
# Verify that the folder url is valid
|
||||
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 the folder
|
||||
|
|
|
@ -31,7 +31,7 @@ class CloudPlatform(ABC):
|
|||
|
||||
def import_from_folder(self, folder_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')
|
||||
|
||||
# Parse the url and get all necessary information
|
||||
|
|
|
@ -23,7 +23,7 @@ class CloudLibrary(PlatformExtension):
|
|||
|
||||
def serialize(self, **kwargs):
|
||||
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'])
|
||||
server_url_field = self.get_server_url_field()
|
||||
stored_value = server_url_field.get_stored_value(ds)
|
||||
|
@ -102,7 +102,7 @@ class GetAllFoldersTaskView(TaskView):
|
|||
def get(self, request, 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)
|
||||
|
||||
ds = get_current_plugin().get_user_data_store(request.user)
|
||||
|
|
|
@ -7,7 +7,7 @@ platforms = None
|
|||
def get_all_platforms():
|
||||
# Cache platforms search
|
||||
global platforms
|
||||
if platforms == None:
|
||||
if platforms is None:
|
||||
platforms = read_platform_from_files()
|
||||
return platforms
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ def update_token(request, token):
|
|||
def get_ddb(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.')
|
||||
|
||||
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)
|
||||
|
||||
# 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)
|
||||
|
||||
try:
|
||||
|
@ -90,7 +90,7 @@ class OrganizationsTaskView(TaskView):
|
|||
class DatasetsTaskView(TaskView):
|
||||
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)
|
||||
|
||||
try:
|
||||
|
@ -107,7 +107,7 @@ class DatasetsTaskView(TaskView):
|
|||
class FoldersTaskView(TaskView):
|
||||
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)
|
||||
|
||||
try:
|
||||
|
@ -127,7 +127,7 @@ class VerifyUrlTaskView(TaskView):
|
|||
# Read form data
|
||||
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)
|
||||
|
||||
_, username, password, _ = get_settings(request)
|
||||
|
@ -161,7 +161,7 @@ class ImportDatasetTaskView(TaskView):
|
|||
# Read form data
|
||||
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)
|
||||
|
||||
registry_url, orgSlug, dsSlug, folder = parse_url(ddb_url).values()
|
||||
|
@ -208,7 +208,7 @@ def import_files(task_id, carrier):
|
|||
|
||||
headers = {}
|
||||
|
||||
if carrier['token'] != None:
|
||||
if carrier['token'] is not None:
|
||||
headers['Authorization'] = 'Bearer ' + carrier['token']
|
||||
|
||||
def download_file(task, file):
|
||||
|
@ -252,7 +252,7 @@ class CheckUrlTaskView(TaskView):
|
|||
combined_id = "{}_{}".format(project_pk, pk)
|
||||
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)
|
||||
else:
|
||||
return Response({'ddbUrl': data['ddbWebUrl']}, status=status.HTTP_200_OK)
|
||||
|
@ -282,7 +282,7 @@ def ddb_cleanup(sender, task_id, **kwargs):
|
|||
class StatusTaskView(TaskView):
|
||||
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
|
||||
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))
|
||||
|
||||
# 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)
|
||||
|
||||
base = linear_func((x_grid, y_grid), *params)
|
||||
|
|
|
@ -17,7 +17,7 @@ def send(subject : str, message : str, smtp_config : dict = None):
|
|||
timeout=10
|
||||
)
|
||||
|
||||
result = send_mail(
|
||||
send_mail(
|
||||
subject,
|
||||
message,
|
||||
smtp_config.get('smtp_from_address'),
|
||||
|
|
|
@ -75,7 +75,8 @@ def hours_minutes_secs(milliseconds):
|
|||
h = milliseconds // ch
|
||||
m = (milliseconds - h * ch) // cm
|
||||
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:
|
||||
m += 1
|
||||
|
|
Ładowanie…
Reference in New Issue