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
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: How to run Addon Manager in Headless mode?

Post by sgrogan »

Kunda1 wrote: Wed Oct 23, 2019 11:12 pm Could this be used on any of the addons ?
Looks like it would work for updates.
To avaoid a restart maybe some code could be lifted from here https://github.com/FreeCAD/FreeCAD/blob ... CADInit.py?

Great thread btw, I'm learning a lot from vocx :)
"fight the good fight"
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 »

sgrogan wrote: Thu Oct 24, 2019 9:08 pm Great thread btw, I'm learning a lot from vocx
likewise :)

BTW, a nice little hack to help me test workbench updates.

Code: Select all

git reset --hard HEAD~1 
This will drop the most recent git commit so that the repo is trailing master by 1 commit and therefore requires an update.
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
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: How to run Addon Manager in Headless mode?

Post by sgrogan »

Kunda1 wrote: Thu Oct 24, 2019 10:54 pm This will drop the most recent git commit so that the repo is trailing master by 1 commit and therefore requires an update.
gitpython is pretty cool

Code: Select all

repo.git.reset('--hard','origin/master~1')
"fight the good fight"
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: How to run Addon Manager in Headless mode?

Post by vocx »

sgrogan wrote: Thu Oct 24, 2019 11:25 pm gitpython is pretty cool
I mean, as long as the external workbenches and macros are collected in Git repositories it sounds like the Addon Manager should basically wrap around the gitpython functions. However, it seems that GitPython is entirely optional. I wonder if it makes sense to not use gitpython. It seems using this module would greatly simplify this headless mode that Kunda tries to implement. Of course, it's one more dependency, but, well, perhaps it's an important and basic one that it just makes sense to use it.
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
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: How to run Addon Manager in Headless mode?

Post by sgrogan »

vocx wrote: Fri Oct 25, 2019 12:36 am I mean, as long as the external workbenches and macros are collected in Git repositories it sounds like the Addon Manager should basically wrap around the gitpython functions. However, it seems that GitPython is entirely optional. I wonder if it makes sense to not use gitpython. It seems using this module would greatly simplify this headless mode that Kunda tries to implement. Of course, it's one more dependency, but, well, perhaps it's an important and basic one that it just makes sense to use it.
You're exactly correct. Now gitpython is the default with .zip fall back. The fall back was because of Windows and problems with py2. With py3 this is no longer an issue and the .7z, .AppImage, and .dmg's support gitpython for py3.

Your instincts are correct though. I think the BIM and Parts Library addons both need gitpython, I'm not sure how well the .zip fall back works.

Now gitpython is not a hard dependency so maybe it should be wrapped in a try/except block.

@vocx, TIA for the education on this matter.
"fight the good fight"
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 »

painfully slow, but it's happening
script can now auto-update all addons at the moment
pdbpp's prettyprint function is awesome.
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 »

Noticed a bug a while ago in the Addon Manager and am trying to get around it using the headless script.
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 »

Milestone: This revision when run will auto-update all addons from the CLI

To test:

Code: Select all

wget https://gist.githubusercontent.com/luzpaz/f3bfaaef8aaec9c66b96e0941f6ed7a5/raw/185540a1d1cdb55955c6cb84346c76a7598de6e5/AddonMangerHeadless.py
freecadcmd -c 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 »

Adopting yorik's code makes it seem like it's a simple thing. 2 things I'm learning:
1) I appreciate everyone who codes and contributes to FC
2) programming is quite a mental exercise, especially when learning it.

Was able to install addons which is cool...
next is to remove them.

The code quality is going to be crappy, y'all. Just sayin'
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 »

BTW, Since it's a gist, feel free to 'fork it and work it' if you want :)
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
Post Reply