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

Conversation

tomasMizera
Copy link
Contributor

As a follow-up of MerginMaps/python-api-client#223. Removes outdated validation of a server URL.

Requires a new py-api release.

@tomasMizera tomasMizera added the requires dependency release Other dependencies must be released before this one label Nov 29, 2024
@jsjtadie
Copy link

In Python, if you want to remove the use of deprecated server authentication, it depends on the specific library or framework you're using. For example, in some cases related to HTTP requests, you might need to update the way you handle authentication methods.

Let's say you were using an older version of  urllib  and had some deprecated server auth code like this:

import urllib.request

Old deprecated way (for example's sake, might not be actual deprecated code like this)

auth_handler = urllib.request.HTTPBasicAuthHandler()
opener = urllib.request.build_opener(auth_handler)
urllib.request.install_opener(opener)
 

You'd need to switch to a more modern and recommended approach. For instance, using  requests  library which has a cleaner and up-to-date way to handle authentication:

import requests

Using requests for authentication

response = requests.get('https://example.com', auth=('username', 'password'))
 

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))

@@ -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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requires dependency release Other dependencies must be released before this one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants