diff --git a/gui/app.py b/gui/app.py index c52a9db..607abf1 100644 --- a/gui/app.py +++ b/gui/app.py @@ -2085,78 +2085,86 @@ def gps_test_start(): global gps_test_service - if get_scanner_status()["running"]: + with scanner_lock: - with scanner_lock: + if ( + scanner_starting + or + ( + scanner_process is not None + and + scanner_process.poll() is None + ) + ): scanner_output.append( "[GUI] GPS test cannot start " "while scanner is running." ) - return jsonify( - { - "ok": False, - "error": - "GPS test cannot start " - "while scanner is running." - } - ), 409 - - with gps_test_lock: - - if ( - gps_test_service is not None - and - gps_test_service.running - ): - return jsonify( { "ok": False, "error": - "GPS test is already running." + "GPS test cannot start " + "while scanner is running." } ), 409 - try: + with gps_test_lock: - cfg = Config() - - gps_test_service = GPSTestService( - cfg, - callback=gps_test_output - ) - - if not gps_test_service.start(): - - gps_test_service = None + if ( + gps_test_service is not None + and + gps_test_service.thread is not None + and + gps_test_service.thread.is_alive() + ): return jsonify( { "ok": False, "error": - "Failed to start GPS test." + "GPS test is already running." } - ), 500 + ), 409 - except Exception as error: + try: - gps_test_service = None + cfg = Config() - with scanner_lock: + gps_test_service = GPSTestService( + cfg, + callback=gps_test_output + ) + + if not gps_test_service.start(): + + gps_test_service = None + + return jsonify( + { + "ok": False, + "error": + "Failed to start GPS test." + } + ), 500 + + except Exception as error: + + gps_test_service = None scanner_output.append( f"[GUI] Failed to start GPS test: " f"{error}" ) - return jsonify( - { - "ok": False, - "error": str(error) - } - ), 500 + return jsonify( + { + "ok": False, + "error": str(error) + } + ), 500 return jsonify( { @@ -2425,6 +2433,8 @@ def scanner_start(): with scanner_lock: + scanner_starting = False + scanner_output.append( "[GUI] WiFi interface was not selected." )