How to run Addon Manager in Headless mode?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 »

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
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 »

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)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to run Addon Manager in Headless mode?

Post by openBrain »

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
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 »

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
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 »

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
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 »

Not had much time to devote to this. Hopefully soon. If anyone wants to jump in, feel free to.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 »

Still thinking about this but don't have structured time to sit down and complete this for a while. Anyone interested in doing so?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
zacl
Posts: 63
Joined: Wed Jul 31, 2019 1:15 pm

Re: How to run Addon Manager in Headless mode?

Post by zacl »

Hello, I just worked on Addon Manager to cofigure proxy setting.
Improving this module is pleasant, so I can continue your work :D

I just have difficulties to know what are next officials objectives for the devellopment of the whole module.
Is there a discussions somewhere in the forum or elsewhere?

EDIT : In fact, I already know this topic, so I will ask there : https://forum.freecadweb.org/viewtopic. ... 4&start=50
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: How to run Addon Manager in Headless mode?

Post by vocx »

zacl wrote: Fri Jan 10, 2020 12:53 am ...
I just have difficulties to know what are next officials objectives for the devellopment of the whole module.
...
There aren't any official objectives that I know of. Basically, whatever you can improve is good.

In my first post in this thread I mention the difficulties of achieving what Kunda wants. The code is currently run from a GUI point of view. It would be nice if you could decouple the GUI part from the basic GUI-less actions. This is the way the Draft workbench is structured.

The Draft Workbench defines all functions in Draft.py, while the GUI tools are defined in DraftTools.py.

So, to achieve what Kunda wants, you could write basic functions that don't need the GUI, and call them from the GUI class CommandAddonManager.

If this is done, then you don't need to launch the entire FreeCAD interface to update or install packages, you could do it from a script.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
zacl
Posts: 63
Joined: Wed Jul 31, 2019 1:15 pm

Re: How to run Addon Manager in Headless mode?

Post by zacl »

vocx wrote: Fri Jan 10, 2020 1:55 am There aren't any official objectives that I know of. Basically, whatever you can improve is good.
It seems to be like you said :D It is good to be in an open mind project.
To open the discussion,I have presented my intentions and asked opinion in the dedicaded post.
vocx wrote: Fri Jan 10, 2020 1:55 am The Draft Workbench defines all functions in Draft.py, while the GUI tools are defined in DraftTools.py.
Got it. I understand well this kind of structure cause I already have developped research instrument driver with a frontend (GUI, button and graph) and a backend (communication, drive control, log, data acquisition and calculation)
Post Reply