Addon Manager Redesign 2021

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
chennes
Veteran
Posts: 3904
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Addon Manager Redesign 2021

Post by chennes »

mario52 wrote: Thu Jan 06, 2022 10:32 am why not see the macro wiki page (as the workbench addon display the Github page) ?
This is in process right now, I should have it in the next few days. I need to change how we show web pages.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3904
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Addon Manager Redesign 2021

Post by chennes »

uwestoehr wrote: Thu Jan 06, 2022 2:26 pm Only when you have admin privileges. The issue is that it tries to gain unnecessarily admin permissions to copy a file.
I see some notes in the symlinking code, but I'm not familiar enough with it to understand yet: this is the code that's executing (it's in addonmanager_utilities.py if you want to see it in situ)

Code: Select all

            csl = ctypes.windll.kernel32.CreateSymbolicLinkW
            csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
            csl.restype = ctypes.c_ubyte
            flags = 1 if os.path.isdir(source) else 0
            # set the SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE flag
            # (see https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/#joC5tFKhdXs2gGml.97)
            flags += 2
            if csl(link_name, source, flags) == 0:
                raise ctypes.WinError()
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3904
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Addon Manager Redesign 2021

Post by chennes »

Actually, in the Python documentation they spell the situation out fairly clearly:
On newer versions of Windows 10, unprivileged accounts can create symlinks if Developer Mode is enabled. When Developer Mode is not available/enabled, the SeCreateSymbolicLinkPrivilege privilege is required, or the process must be run as an administrator.

OSError is raised when the function is called by an unprivileged user.
So in the interim since this code was written, it has become nonviable on Windows. I hate having to copy those macros instead of symlinking them, but it appears on Windows that's really the only viable path forward. I'll add code to catch that exception and copy if it's caught.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Addon Manager Redesign 2021

Post by uwestoehr »

chennes wrote: Fri Jan 07, 2022 1:14 am I'll add code to catch that exception and copy if it's caught.
Thanks. I will try if it works for me as Win user-only when you committed this.
User avatar
chennes
Veteran
Posts: 3904
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Addon Manager Redesign 2021

Post by chennes »

@uwestoehr when you have a moment can you please verify that git commit 7ea0394e9 resolves this issue? I am just guessing about which branch of the symlinking code you are running into, based on the Python docs.
uwestoehr wrote: Thu Jan 06, 2022 2:26 pm Ping
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3904
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Addon Manager Redesign 2021

Post by chennes »

This actually calls my attention to an uninstall problem. Right now the uninstall code works by just deleting the mod directory, but that's not really correct: it will leave dangling symlinks to these macros, and now on Windows will leave copies. I think the functioning copies is preferable, but I think when a user uninstalls a mod the AM should actually uninstall all of it, even these macros. What do you think?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Addon Manager Redesign 2021

Post by uwestoehr »

chennes wrote: Fri Jan 07, 2022 1:29 am when a user uninstalls a mod the AM should actually uninstall all of it, even these macros. What do you think?
Yes, the AM should also delete these macros. Ideally everything is after the uninstallation as it was before. This helps in case there are bugs or files that have been removed in a new addon version and users need to reinstall the addon to fix that properly or to get rid of the removed addon files.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Addon Manager Redesign 2021

Post by uwestoehr »

chennes wrote: Fri Jan 07, 2022 1:24 am @uwestoehr when you have a moment can you please verify that git commit 7ea0394e9 resolves this issue?
Many thanks! This works fine for me. So the issue is fixed.
User avatar
chennes
Veteran
Posts: 3904
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Addon Manager Redesign 2021

Post by chennes »

Thanks again for the report and the testing. I have added the necessary code now to correctly uninstall these macros if they were copied in. git commit ecc6dee17
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
TheMarkster
Veteran
Posts: 5508
Joined: Thu Apr 05, 2018 1:53 am

Re: Addon Manager Redesign 2021

Post by TheMarkster »

If an addon creates parameters these should also be removed during uninstallation or at least give the user the option to remove them. I'm thinking in the package xml file the folder name and hierarchy could be given in a semicolon separated list, and then the entire group removed by the addon manager. Something like:

parameters = "Plugins/MeshRemodel;BaseApp/Preferences/Mod/MeshRemodel;Tux/PersistentToolbars/User/MeshRemodelWorkbench"

Addons should probably only use Plugins/AddonName, but FreeCAD is creating stuff, too, mainly related to toolbars. The stuff FreeCAD creates maybe can be automatically removed if it's based on the workbench name.
Post Reply