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 »

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
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 »

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
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
kkremitzki
Veteran
Posts: 2511
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: How to run Addon Manager in Headless mode?

Post by kkremitzki »

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

Re: How to run Addon Manager in Headless mode?

Post by sgrogan »

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'))
"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: 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
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 »

Added import logging to enable/disable debugging of the script
https://gist.github.com/luzpaz/f3bfaaef ... cc01b504d8
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 »

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
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 »

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 »

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
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 »

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