Modify

Opened 8 months ago

Closed 8 days ago

Last modified 8 days ago

#23688 closed enhancement (fixed)

[PATCH] Open local url using the os instead of the browser

Reported by: Emvee Owned by: team
Priority: normal Milestone:
Component: Plugin utilsplugin2 Version:
Keywords: local url 127.0.0.1 Cc:

Description

I have a local python script that listens on a port and accepts a URL like

http://127.0.0.1:8282/qgis_zoom_to?lat=51.5810865&lon=4.5293149

I did put that in the custom URL configuration of the Utilsplugins2 settings as:

http://127.0.0.1:8282/qgis_zoom_to?lat={#lat}&lon={#lon}

And that will open the browser after which the browser will call the local script.
While this is working it has the drawback that it leaves an empty tab open every time you involve this script and this extra browser step adds latency

What this patch does is to check for a local address and if so, open the url using the Java system functionality. This way I see the script is called without involving the browser.

With the current patch, josm will emit a warning if the local system is not handling the request:

2024-05-22 10:25:42.538 SEVERE: Can not open URL http://127.0.0.1:8282/qgis_zoom_to?lat=51.5810865&lon=4.5293149: java.net.ConnectException: Connection refused

Attachments (2)

local_url.patch (1.7 KB ) - added by Emvee 8 months ago.
at_localhost.patch (1.8 KB ) - added by Emvee 3 months ago.

Download all attachments as: .zip

Change History (12)

by Emvee, 8 months ago

Attachment: local_url.patch added

comment:1 by Emvee, 7 months ago

Milestone: 24.06

comment:2 by stoecker, 6 months ago

Milestone: 24.06

Your check for a local URL is broken. local url's can also be localhost, [::1], 127.1.2.234 and so on. Rather than checking the URL you need to check the subnet, which is 127/8 or ::1/128.

Anyway there is no reason to handle local URLs different. The same topic applies to any URL. Maybe rather than what you did prepend "directcall:" (or maybe another already somehwere else established marker I don't know about) to the URL and when the URL starts with "dircectcall:" strip that and call it directly?

comment:3 by anonymous, 6 months ago

Agreed, using something like "directcall" makes more sense, let me have a look into that and update the patch.

by Emvee, 3 months ago

Attachment: at_localhost.patch added

comment:4 by Emvee, 3 months ago

I did look for some other established marker but have not found one, Microsoft has https://learn.microsoft.com/en-us/windows/uwp/launch-resume/launch-default-app but this is starting other App, not http tp the local machine.

I did work some time with directcall: but I do not like the two colons in directcall:http:// and instead reverted to a @localhost after the link, so for example

http://127.0.0.1:8282/qgis_zoom_to?lat={#lat}&lon={#lon}@localhost

Wondering what others think of this.

Patch attached, at_localhost.patch

comment:5 by stoecker, 3 months ago

Milestone: 24.10

comment:6 by taylor.smock, 2 months ago

Milestone: 24.1024.11

Ticket retargeted after milestone closed

comment:7 by taylor.smock, 5 weeks ago

Milestone: 24.1124.12

Ticket retargeted after milestone closed

comment:8 by stoecker, 8 days ago

In 36362/osm:

see #23688, patch for local URL calling

comment:9 by stoecker, 8 days ago

Resolution: fixed
Status: newclosed

In 36363/osm:

fix #23688, patch for local URL calling (dist)

comment:10 by stoecker, 8 days ago

Milestone: 24.12

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.