MerginMaps / qgis-plugin

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

Downloading project produce a crash in the plugin when server in maitenance mode #586

Open jozef-budac opened 5 months ago

jozef-budac commented 5 months ago

When server is in maitenance mode and you try to download a project, the plugin crash

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 113, in download_start_internal
    self.job = download_project_async(self.mergin_client, self.project_name, self.target_dir)

  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client_pull.py", line 143, in download_project_async
    latest_proj_info = mc.project_info(project_path)

  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client.py", line 692, in project_info
    resp = self.get("/v1/project/{}".format(project_path_or_id), params)

  File "/home/jozef/.local/share/QGIS/QGIS3/profiles/ws/python/plugins/Mergin/mergin/client.py", line 230, in get
    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/tme1/aextractor3
Method: GET
Detail: { "status" : "503", "title" : "Service unavailable", "detail" : "The site is undergoing scheduled maintenance." }

https://github.com/MerginMaps/qgis-plugin/assets/83582181/4dfb5f04-ca7b-4856-9aa9-55fb044c2b44

jozef-budac commented 5 months ago

Another problem is, when the maintenance mode is turn on during project downloading

https://github.com/MerginMaps/qgis-plugin/assets/83582181/ce2f00fd-0aaa-4004-88f2-4cfcd21f5616