How to run Addon Manager in Headless mode?

Need help, or want to share a macro? Post here!
User avatar
sgrogan
Posts: 5585
Joined: Wed Oct 22, 2014 5:02 pm

Re: How to run Addon Manager in Headless mode?

Post by sgrogan » Thu Oct 24, 2019 9:08 pm

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 :)
User avatar
Kunda1
Posts: 6440
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 » Thu Oct 24, 2019 10:54 pm

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

Re: How to run Addon Manager in Headless mode?

Post by sgrogan » Thu Oct 24, 2019 11:25 pm

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')
vocx
Posts: 2829
Joined: Thu Oct 18, 2018 9:18 pm

Re: How to run Addon Manager in Headless mode?

Post by vocx » Fri Oct 25, 2019 12:36 am

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.
To support the documentation effort, and code development, your donation is appreciated: paypal.
User avatar
sgrogan
Posts: 5585
Joined: Wed Oct 22, 2014 5:02 pm

Re: How to run Addon Manager in Headless mode?

Post by sgrogan » Fri Oct 25, 2019 12:53 am

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.
User avatar
Kunda1
Posts: 6440
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 » Fri Oct 25, 2019 3:39 am

painfully slow, but it's happening
script can now auto-update all addons at the moment
pdbpp's prettyprint function is awesome.
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: 6440
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 » Fri Oct 25, 2019 11:46 am

Noticed a bug a while ago in the Addon Manager and am trying to get around it using the headless script.
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: 6440
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 » Fri Oct 25, 2019 12:45 pm

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

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 » Fri Oct 25, 2019 8:57 pm

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'
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: 6440
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Post by Kunda1 » Fri Oct 25, 2019 9:01 pm

BTW, Since it's a gist, feel free to 'fork it and work it' if you want :)
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests