How to run Addon Manager in Headless mode?

Need help, or want to share a macro? Post here!
User avatar
Kunda1
Posts: 5913
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Mon Nov 04, 2019 5:41 pm

Just a note that there is a very detailed section about Reloading Python modules in order to circumvent FC restart in
https://forum.freecadweb.org/viewtopic.php?f=10&t=35383
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Kunda1
Posts: 5913
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Mon Nov 04, 2019 6:57 pm

openBrain wrote:
Sun Nov 03, 2019 11:13 pm
concise summary of what you're trying to achieve, where you are and what is blocking ATM? So I can quickly have a macro vision. Pointers to existing posts are OK as well. :)
The current incarnation of the code: https://gist.github.com/luzpaz/f3bfaaef ... 941f6ed7a5 (Revision 15)
You can git clone it by:

Code: Select all

$ git clone https://gist.github.com/f3bfaaef8aaec9c66b96e0941f6ed7a5.git AddonManagerHeadless.py
$ freecadcmd AddonManagerHeadless.py
Note: running this script can change your FreeCAD environment. So you may want to backup your environment cp ~/.FreeCAD/ ~/.FreeCAD.bak/

Usage:

Code: Select all

CLI Addon Manager
Usage:
	list			 lists all official addons + which are currently installed
	check			 check what addons have Updates
	updateall		 update all addons that have pending updates

	install <addon> [<addon>] installs valid (case-sensitive) addons
	remove  <addon> [<addon>] remove valid (case-sensitive) addons
List of what flags trigger what functions:
  • list - ListRepo()
  • check - ListRepo() + CheckUpdateRepo()
  • updateall - ListRepo() + CheckUpdateRepo() + UpdateRepo()
  • install - ListRepo() + CheckRequested() + InstallRepo()
  • remove - RemoveRepo()


Status
Currently the list and check functionalities work (but check actually may be updating as well, which it shouldn't) but I'd like to refine them so that if someone wants to mute the output the can use a flag to do so. Also I'd like to list the columns alphabetically from top to bottom instead of across.

updateall and install aren't functioning correctly, I broke them fiddling with the gitpython module tweaks trying output the progress bar of a git pull to print to STDOUT. In fact, I don't think the script is installing the Addons correctly anymore because when I want to rollback a commit in one of the addons for testing purposes I get an unexpected output when I run git status showing that there is no different between local and upstream. See https://forum.freecadweb.org/viewtopic. ... 40#p343692

remove works but isn't correctly removing addons since they also require removal from user.cfg so that needs to be done at some point as well by figuring out what the uninstall parameters are and executing them through the script.

I'd also like to follow @vocx's advice and turn this script in to an importable module (https://forum.freecadweb.org/viewtopic. ... 10#p342917)
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
openBrain
Posts: 2342
Joined: Fri Nov 09, 2018 5:38 pm

Re: How to run Addon Manager in Headless mode?

Postby openBrain » Mon Nov 04, 2019 7:07 pm

For my clear understanding : is that coded from scratch or do you modify the existing GUI manager?
Also have you identified some priorities in the todos?
I'll have a look ASAP but unfortunately can't promise any deadline ATM. ;)
User avatar
Kunda1
Posts: 5913
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Mon Nov 04, 2019 8:48 pm

openBrain wrote:
Mon Nov 04, 2019 7:07 pm
For my clear understanding : is that coded from scratch or do you modify the existing GUI manager?
Also have you identified some priorities in the todos?
I'll have a look ASAP but unfortunately can't promise any deadline ATM. ;)
Modified the existing GUI manager, basically cut and pasted most of the following: AddonManager.py
and
addonmanager_workers.py
just removed all the Qt code and some other extraneous code

https://github.com/FreeCAD/FreeCAD/tree ... donManager
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Kunda1
Posts: 5913
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Tue Nov 05, 2019 1:58 pm

openBrain wrote:
Mon Nov 04, 2019 7:07 pm
Also have you identified some priorities in the todos?
The Todos listed in the script are later down the roadmap. Most importantly is:
  • the check, udateall, install, and remove linked functions need to be fixed.
  • the sys.argv[] method is inferior because currently it hardcodes argv[3] and above as command line variables, which is wrong here's the usecase:
    The script currently assumes this will be the input
    ./AppRun -c ../AddonManagerHeadless.py
    where in reality it will be
    freecadcmd AddonManagerHeadless.py
    or
    ./AppRun -c -M /usr/lib/python3.7/site-packages ../AddonManagerHeadless.py
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Kunda1
Posts: 5913
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Mon Nov 11, 2019 2:36 pm

Not had much time to devote to this. Hopefully soon. If anyone wants to jump in, feel free to.
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Kunda1
Posts: 5913
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Tue Nov 26, 2019 8:34 pm

Still thinking about this but don't have structured time to sit down and complete this for a while. Anyone interested in doing so?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features