Skip to content

wxGUI/extensions: fix reinstall/uninstall multi-addon e.g. wx.metadata#2452

Open
tmszi wants to merge 6 commits intoOSGeo:mainfrom
tmszi:wxgui_ext_fix_reinstall_multi_addon
Open

wxGUI/extensions: fix reinstall/uninstall multi-addon e.g. wx.metadata#2452
tmszi wants to merge 6 commits intoOSGeo:mainfrom
tmszi:wxgui_ext_fix_reinstall_multi_addon

Conversation

@tmszi
Copy link
Member

@tmszi tmszi commented Jun 19, 2022

Describe the bug
It is not possible reinstall multi-addon via wxGUI Manage installed GRASS Addons extensions.

To Reproduce
Steps to reproduce the behavior:

  1. Launch wxGUI
  2. Install some multi-addon e.g. g.extension wx.metadata
  3. From main window menu choose Settings -> Addons extensions - > Manage installed extension
  4. On the Manage installed GRASS Addons extensions window from the list of extensions check checkbox widget for g.gui.metadata addon
  5. Hit Reinstall button
  6. See error
WARNING: Extension <g.gui.metadata> already installed. Re-installing...
Fetching <g.gui.metadata> from GRASS GIS Addons repository (be patient)...
svn: E170000: URL 'https://github.com/OSGeo/grass-
addons/branches/grass8/src/general/g.gui.metadata' doesn't
exist
ERROR: GRASS Addons <g.gui.metadata> not found

Expected behavior
Reinstall multi-addon via wxGUI Manage installed GRASS Addons extensions should be work.

System description (please complete the following information):

  • Operating System: all
  • GRASS GIS version: all

Additional context
The g.extension.all module has an implemented find multi-addon name function.

def find_addon_name(addons):

@tmszi tmszi added bug Something isn't working backport_needed GUI wxGUI related labels Jun 19, 2022
@tmszi tmszi added this to the 8.2.1 milestone Jun 19, 2022
@neteler neteler modified the milestones: 8.2.1, 8.2.2 Jan 22, 2023
@wenzeslaus wenzeslaus modified the milestones: 8.2.2, 8.3.1 Jun 6, 2023
@tmszi tmszi modified the milestones: 8.3.1, 8.4.0 Sep 27, 2023
@neteler
Copy link
Member

neteler commented Oct 4, 2023

@tmszi would you mind to rebase this PR?

@tmszi
Copy link
Member Author

tmszi commented Oct 6, 2023

@tmszi would you mind to rebase this PR?

Yes, I will do it as soon as I have more free time. Plus PR also needs to be improved.

@landam
Copy link
Member

landam commented Nov 20, 2023

Also conflicts have to be solved.

@neteler
Copy link
Member

neteler commented May 1, 2024

I have tried this in the current "main" (8.4) GUI and it worked:

g.extension extension=g.gui.metadata operation=add                              
WARNING: Extension <g.gui.metadata> already installed. Re-installing...
Fetching <g.gui.metadata> from <https://github.com/OSGeo/grass-addons/> (be patient)...
Already on 'grass8'
Compiling...
Your branch is up to date with 'origin/grass8'.
Installing...
Updating extensions metadata file...
Updating extension modules metadata file...
Installation of <g.gui.metadata> successfully finished
(Wed May  1 23:22:33 2024) Command finished (11 sec)  

Maybe I didn't test correctly to trigger the bug?

@tmszi
Copy link
Member Author

tmszi commented May 2, 2024

I have tried this in the current "main" (8.4) GUI and it worked:

g.extension extension=g.gui.metadata operation=add                              
WARNING: Extension <g.gui.metadata> already installed. Re-installing...
Fetching <g.gui.metadata> from <https://github.com/OSGeo/grass-addons/> (be patient)...
Already on 'grass8'
Compiling...
Your branch is up to date with 'origin/grass8'.
Installing...
Updating extensions metadata file...
Updating extension modules metadata file...
Installation of <g.gui.metadata> successfully finished
(Wed May  1 23:22:33 2024) Command finished (11 sec)  

Maybe I didn't test correctly to trigger the bug?

Important step is reinstalling/removing extension via wxGUI only (main window menu -> Settings -> Addons extensions - > Manage installed extension). But yes you are right it is seems reinstalling extensions works as expected, but removing extension still not.

@echoix
Copy link
Member

echoix commented Jun 1, 2024

Is this now out of scope for 8.4.0?

@neteler
Copy link
Member

neteler commented Jun 2, 2024

@tmszi would you mind to rebase this PR again? This would simplify testing and make it (hopefully) 8.4.0 ready.

@tmszi
Copy link
Member Author

tmszi commented Jun 2, 2024

@tmszi would you mind to rebase this PR again? This would simplify testing and make it (hopefully) 8.4.0 ready.

Yes I agree with you. I have had limited my free time last weeks. I think this PR will also require code refactoring. I will try to resolve this as quickly as possible.

@tmszi tmszi force-pushed the wxgui_ext_fix_reinstall_multi_addon branch from 333b273 to faac751 Compare June 5, 2024 09:43
@github-actions github-actions bot added the Python Related code is in Python label Jun 5, 2024
from pathlib import Path
from urllib.parse import urlparse

import xml.etree.ElementTree as etree

Check notice

Code scanning / Bandit

Using xml.etree.ElementTree to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree with the equivalent defusedxml package, or make sure defusedxml.defuse_stdlib() is called.

Using xml.etree.ElementTree to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree with the equivalent defusedxml package, or make sure defusedxml.defuse_stdlib() is called.
response_format="application/xml",
file_name=os.path.basename(urlparse(url).path),
)
tree = etree.fromstring(response.read())

Check warning

Code scanning / Bandit

Using xml.etree.ElementTree.fromstring to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree.fromstring with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called

Using xml.etree.ElementTree.fromstring to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree.fromstring with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
opener = urlrequest.build_opener(proxy)
urlrequest.install_opener(opener)
request = urlrequest.Request(url, headers=HEADERS)
return urlrequest.urlopen(request, *args, **kwargs)

Check warning

Code scanning / Bandit

Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.

Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.
@tmszi
Copy link
Member Author

tmszi commented Jun 5, 2024

Rebase was successful and tests passed successful too.

@tmszi
Copy link
Member Author

tmszi commented Jun 5, 2024

For testing purpose:

  1. Install some multi-addon e.g. g.extension wx.metadata
  2. Via GUI open Manage installed extension dialog (from the main window menu choose Settings -> Addons extensions - > Manage installed extension)
  3. Select e.g. g.gui.metadata addon from the list of the installed addons
  4. Hit uninstall button widget
  5. And check if wx.metadata multi-addon was successfully uninstalled with command g.extension -a or via GUI

Comment on lines +2078 to +2094
>>> addons = find_addon_name(
... addons=[
... "g.gui.metadata",
... "g.gui.cswbrowser",
... "db.csw.run",
... "db.csw.harvest",
... "db.csw.admin",
... "v.info.iso",
... "r.info.iso",
... "t.info.iso",
... "db.join",
... ]
... )
>>> addons.sort()
>>> addons
['db.join', 'wx.metadata']
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand this example result, why only those 2 addons?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure I understand this example result, why only those 2 addons?

wx.metadata is multi-addon (contains g.gui.metadata addon, g.gui.cswbrowser addon and etc.), we need identify multi-addon name which is in this example wx.metadata if user want uninstalling multi-addon (see GUI Manage installed extension dialog list of installed addon after you install some multi-addon e.g. wx.metadata)

@petrasovaa petrasovaa modified the milestones: 8.4.0, 8.4.1 Jun 10, 2024
@wenzeslaus wenzeslaus modified the milestones: 8.4.1, 8.5.0 Nov 5, 2024
@echoix echoix added the conflicts/needs rebase Rebase to or merge with the latest base branch is needed label Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working conflicts/needs rebase Rebase to or merge with the latest base branch is needed general GUI wxGUI related libraries module Python Related code is in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants