Kunda1 wrote: ↑Tue Oct 22, 2019 9:28 pm
...
What I'm trying to do specifically is first access functions within
src/Mod/AddonManager/ like querying the FreeCAD-addons Github repo, and listing their contents, listing what addons currently live in the local machine, list which addons have updated, install an addon/macro, remove and addon/macro etc...
It seems the Addon Manager was more or less designed to be utilized from the graphical interface, so it doesn't have a proper scripting interface for non-GUI usage. The primary graphical command, what I call, a GuiCommand, is defined in
AddonManager.py (class
CommandAddonManager).
The top imports indicate the low level functions that are actually used by the GuiCommand.
Code: Select all
import addonmanager_utilities as utils
from addonmanager_utilities import translate # this needs to be as is for pylupdate
from addonmanager_workers import *
https://github.com/FreeCAD/FreeCAD/blob ... ger.py#L69
The
Activated() function indicates which code is run when the Addon Manager is launched. It just calls
launch(). This command sets up the graphical interface through the
AddonManager.ui file, but then it calls the actual functions that do stuff.
Code: Select all
# populate the list
self.update()
So, what does
update() do? The function
update() calls a class that is probably defined in one of the imported modules,
addonmanager_workers.
Code: Select all
self.update_worker = UpdateWorker()
Then it does all sorts of actions defined in this
UpdateWorker class.
It seems this
addonmanager_workers.py module has the classes that actually do work. But they are coded in such a way that they are tightly connected with the graphical interface because they use things like progress bars and labels. In order to run these commands entirely without the graphical interface you would need to decouple the functionality of those classes.
https://github.com/FreeCAD/FreeCAD/blob ... rs.py#L557
For example, the class
InstallWorkbench has a
run() method which seems to do actual work to install new workbenches. But this method also accesses the elements of the graphical .ui file. You need to break this coupling.
Code: Select all
self.info_label.emit("no zip support.")
...
self.info_label.emit("Updating module...")
Said in another way, you need to write your own functions that just do stuff, but don't access the graphical interface at all. Then from the graphical interface you could call these new functions.
Then you would have something like
Code: Select all
import addonmanager_core as core
GraphicalCode():
do_some_stuff() # GUI stuff
arrange_labels() # GUI stuff
result = core.call_basic_functions(repo) # Non GUI stuff, Git or whatever behind the scenes
updated = core.call_update(workbench) # Non GUI stuff, Git or whatever behind the scenes
do_more_stuff(result, updated) # GUI stuff that does something with the results of the non-GUI functions