MerginMaps / qgis-plugin

QGIS plugin for managing Mergin Maps projects
GNU General Public License v3.0
32 stars 13 forks source link

When server get's into maintenance mode during synchronization, the plugin crash #585

Open jozef-budac opened 3 weeks ago

jozef-budac commented 3 weeks ago

When the server gets into maintenance mode during synchronization, the plugin crash

Scenario 1) have a big project that will synchronize for a while. 2) Hit the synchronize button 3) During synchronization, turn on maintenance mode -> the plugin crash

An error has occurred while executing Python code: 

Mergin.mergin.common.ClientError: HTTP Error: 503 Service Unavailable URL: https://app.dev.merginmaps.com/v1/project/push/cancel/be6cdecf-a324-4b85-b381-971c7212a8a3 Method: POST Detail: { "status" : "503", "title" : "Service unavailable", "detail" : "The site is undergoing scheduled maintenance." } 
Traceback (most recent call last):
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client.py", line 206, in _do_request
    return self.opener.open(request)
  File "/usr/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/usr/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/sync_dialog.py", line 205, in push_timer_tick
    is_running = push_project_is_running(self.job)
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client_push.py", line 220, in push_project_is_running
    raise future.exception()
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client_push.py", line 315, in _do_upload
    item.upload_blocking(job.mc, job.mp)
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client_push.py", line 69, in upload_blocking
    resp = mc.post("/v1/project/push/chunk/{}/{}".format(self.transaction_id, self.chunk_id), data, headers)
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client.py", line 237, in post
    return self._do_request(request)
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client.py", line 195, in wrapper
    return f(self, *args)
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client.py", line 220, in _do_request
    raise ClientError(error_msg)
Mergin.mergin.common.ClientError: HTTP Error: 503 Service Unavailable
URL: https://app.dev.merginmaps.com/v1/project/push/chunk/be6cdecf-a324-4b85-b381-971c7212a8a3/218a39ff-136b-4fdb-aca0-14c4e924104e
Method: POST
Detail: { "status" : "503", "title" : "Service unavailable", "detail" : "The site is undergoing scheduled maintenance." }

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client.py", line 206, in _do_request
    return self.opener.open(request)
  File "/usr/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/usr/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/sync_dialog.py", line 63, in timer_timeout
    self.push_timer_tick()
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/sync_dialog.py", line 210, in push_timer_tick
    push_project_cancel(self.job)
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client_push.py", line 306, in push_project_cancel
    raise err
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client_push.py", line 302, in push_project_cancel
    resp_cancel = job.mc.post("/v1/project/push/cancel/%s" % job.transaction_id)
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client.py", line 237, in post
    return self._do_request(request)
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client.py", line 195, in wrapper
    return f(self, *args)
  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client.py", line 220, in _do_request
    raise ClientError(error_msg)
Mergin.mergin.common.ClientError: HTTP Error: 503 Service Unavailable
URL: https://app.dev.merginmaps.com/v1/project/push/cancel/be6cdecf-a324-4b85-b381-971c7212a8a3
Method: POST
Detail: { "status" : "503", "title" : "Service unavailable", "detail" : "The site is undergoing scheduled maintenance." }

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] 
QGIS version: 3.34.7-Prizren Prizren, 6f7d735cae3 

Python Path:
/usr/share/qgis/python
/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python
/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python310.zip
/usr/lib/python3.10
/usr/lib/python3.10/lib-dynload
/home/jozef/.local/lib/python3.10/site-packages
/usr/local/lib/python3.10/dist-packages
/usr/lib/python3/dist-packages
/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python
.
/home/jozef/Lutra/projects/a/a6
jozef-budac commented 3 weeks ago

I was not able to even close the window with Cancel button https://github.com/MerginMaps/qgis-plugin/assets/83582181/5f058593-97b1-4d5d-a0de-124ec52cfd5a