How to run Addon Manager in Headless mode?

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

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Sat Oct 26, 2019 1:53 pm

Made some headway by adding command line parsing
But i hit a wall
list index out of range
Also I still haven't successfully compiled FC-dev... so still using the appimage for testing.
Therefore I haven't 'modularized' the script at all.

Testers needed:

Code: Select all

wget https://gist.githubusercontent.com/luzpaz/f3bfaaef8aaec9c66b96e0941f6ed7a5/raw/3e7033c4dfe11771ee76911648be875e1298eada/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: 5927
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Sat Oct 26, 2019 4:40 pm

Kunda1 wrote:
Sat Oct 26, 2019 1:53 pm
list index out of range
Buh, this sucks. I know it has something to do with the sys.argv[] stuff at the end of the script... but I can't figure it out
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
kkremitzki
Posts: 1795
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: How to run Addon Manager in Headless mode?

Postby kkremitzki » Sat Oct 26, 2019 5:00 pm

Kunda1 wrote:
Sat Oct 26, 2019 4:40 pm
Kunda1 wrote:
Sat Oct 26, 2019 1:53 pm
list index out of range
Buh, this sucks. I know it has something to do with the sys.argv[] stuff at the end of the script... but I can't figure it out
Can you post the full error message? I don't get it when trying your reproduction steps above.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
sgrogan
Posts: 5469
Joined: Wed Oct 22, 2014 5:02 pm

Re: How to run Addon Manager in Headless mode?

Postby sgrogan » Sat Oct 26, 2019 5:14 pm

line #39, readline isn't a module, removing this.
line #322

Code: Select all

>>> print("{0}\n".format(sys.argv))
['C:\\Users\\Chris\\GitHub\\FreeCAD-build2\\bin\\FreeCAD.exe']
then the error on line 323

Code: Select all

Traceback (most recent call last):
  File "C:/Users/Chris/AppData/Roaming/FreeCAD/Macro/headless.FCMacro", line 323, in <module>
    if sys.argv[3] == "list":
<class 'SyntaxError'>: ('invalid syntax', ('C:/Users/Chris/AppData/Roaming/FreeCAD/Macro/headless.FCMacro', 323, 13, '    print sys.argv[3]\n'))
User avatar
Kunda1
Posts: 5927
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Sat Oct 26, 2019 5:52 pm

sgrogan wrote:
Sat Oct 26, 2019 5:14 pm
line #39, readline isn't a module, removing this.
line #322

Code: Select all

>>> print("{0}\n".format(sys.argv))
['C:\\Users\\Chris\\GitHub\\FreeCAD-build2\\bin\\FreeCAD.exe']
then the error on line 323

Code: Select all

Traceback (most recent call last):
  File "C:/Users/Chris/AppData/Roaming/FreeCAD/Macro/headless.FCMacro", line 323, in <module>
    if sys.argv[3] == "list":
<class 'SyntaxError'>: ('invalid syntax', ('C:/Users/Chris/AppData/Roaming/FreeCAD/Macro/headless.FCMacro', 323, 13, '    print sys.argv[3]\n'))
Thanks, that fixed it.

Update script.
https://gist.github.com/luzpaz/f3bfaaef ... 7739c95870
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: 5927
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Sat Oct 26, 2019 6:21 pm

Added import logging to enable/disable debugging of the script
https://gist.github.com/luzpaz/f3bfaaef ... cc01b504d8
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: 5927
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Sat Oct 26, 2019 7:10 pm

https://gist.github.com/luzpaz/f3bfaaef ... ss-py-L180

Code: Select all

            gitrepo = git.Git(clonedir)
clonedir == ~/.FreeCAD/Mod/<addon_name>

so essentially it's

Code: Select all

            gitrepo = git.Git(~/.FreeCAD/Mod/<addon_name>)
I don't understand what git.Git is doing here. Can't find mention of it in the GitPython API for git.Git
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: 5927
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Sat Oct 26, 2019 9:44 pm

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

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Sun Oct 27, 2019 12:23 am

Figured out the list index out of range issue. It was the way i was using sys.argv to check items in the list. Fixed it. But then something else broke. I'm still confused as to what the function of git.Git() does
https://forum.freecadweb.org/posting.ph ... 9#pr343385
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: 5927
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to run Addon Manager in Headless mode?

Postby Kunda1 » Sun Oct 27, 2019 12:57 am

Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features