Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated server validation use #648

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Mergin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,13 @@ def send_logs(username, logfile):

def validate_mergin_url(url):
"""
Validation of mergin URL by pinging. Checks if URL points at compatible Mergin server.
Initiates connection to the provided server URL to check if the server is accessible
:param url: String Mergin Maps URL to ping.
:return: String error message as result of validation. If None, URL is valid.
"""
try:
mc = MerginClient(url, proxy_config=get_qgis_proxy_config(url))
if not mc.is_server_compatible():
return "Incompatible Mergin Maps server"
_ = MerginClient(url, proxy_config=get_qgis_proxy_config(url))
Copy link
Contributor

@ValentinBuira ValentinBuira Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The python convention is to use _ as a throwaway when we absolutely need place holder variable (e.g unpack variables), here I think we can just remove it altogether

Suggested change
_ = MerginClient(url, proxy_config=get_qgis_proxy_config(url))
MerginClient(url, proxy_config=get_qgis_proxy_config(url))


# Valid but not Mergin URl
except ClientError:
return "Invalid Mergin Maps URL"
Expand Down Expand Up @@ -1223,7 +1222,7 @@ def test_server_connection(url, username, password):
result = True, "<font color=green> OK </font>"
proxy_config = get_qgis_proxy_config(url)
try:
mc = MerginClient(url, None, username, password, get_plugin_version(), proxy_config)
_ = MerginClient(url, None, username, password, get_plugin_version(), proxy_config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

except (LoginError, ClientError) as e:
QgsApplication.messageLog().logMessage(f"Mergin Maps plugin: {str(e)}")
result = False, f"<font color=red> Connection failed, {str(e)} </font>"
Expand Down
Loading