check workbench update with AddonManager

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
rockn
Veteran
Posts: 1791
Joined: Wed Sep 28, 2011 10:39 am
Location: Toulouse, France
Contact:

check workbench update with AddonManager

Post by rockn »

Hello,
I would like to know if it's possible to check the up to date status of an installed workbench with the help of the AddonManager module ?

Something like :

Code: Select all

import AddonManager
uptodate = AddonManager.checkWB('My Workbench')
uptodate
>>> [False, 10 commits behind]
>>> [True, 0 commitsbehind] 
The goal is to make a check for update when wortkbench is activated, and this without the need to code some fetching functions in the Init of the workbench.

For reference : i found this thread https://forum.freecadweb.org/viewtopic.php?f=10&t=27621 but I'm wondering if it can be done though addonmanager.
Formations - Assistance - Développement : https://freecad-france.com
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: check workbench update with AddonManager

Post by Kunda1 »

This is a great idea. posting in order to subscribe to this thread since this should be documented if it exists.
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
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: check workbench update with AddonManager

Post by yorik »

I did something like that for the BIM workbench already:
https://github.com/yorikvanhavre/BIM_Wo ... ds.py#L635
We could make the worker class usable for other workbenches too, something like def __init__(self,workbenchname) and add it to the Addon code...
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: check workbench update with AddonManager

Post by DeepSOIC »

could we also offer releases somehow? Or branch selection? I would like to leave a branch of part-o-magic that works with 0.17/0.18, and continue to advance it using new stuff in 0.19 without the burden of backward compatibility.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: check workbench update with AddonManager

Post by vocx »

DeepSOIC wrote: Fri Aug 16, 2019 12:13 am could we also offer releases somehow? Or branch selection? I would like to leave a branch of part-o-magic that works with 0.17/0.18, and continue to advance it using new stuff in 0.19 without the burden of backward compatibility.
I think this is basically what Roy is requesting in this other thread BIM Addon version nr?

I guess the addons aren't particularly tracked. Developers mostly use a rolling release model, although I've seen a few who actually name a few releases as v1, v2, etc.
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
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: check workbench update with AddonManager

Post by Kunda1 »

vocx wrote: Fri Aug 16, 2019 12:56 am I guess the addons aren't particularly tracked. Developers mostly use a rolling release model, although I've seen a few who actually name a few releases as v1, v2, etc.
Yes, the rolling release model is the dominant paradigm.

Edit: hard to track and troubleshoot. I was at one point advocating for https://github.com/FreeCAD/FreeCAD-addons/issues/105 (Document how Workbench creators can inject WB version in to About FreeCAD dialog)
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
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: check workbench update with AddonManager

Post by TheMarkster »

It would be better if the addon manager can do this check on startup for all installed workbenches / macros? This would relieve the addon authors from all having to implement update checking code into their macros / workbenches.

I'm thinking having the addon manager run on startup in the background, hidden. It does the same check it does now, and if updates are found, the user gets notified and asked whether to update now. Could also give the user the option to disable this automatic checking feature at that point.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: check workbench update with AddonManager

Post by Kunda1 »

DeepSOIC wrote: Fri Aug 16, 2019 12:13 am could we also offer releases somehow? Or branch selection? I would like to leave a branch of part-o-magic that works with 0.17/0.18, and continue to advance it using new stuff in 0.19 without the burden of backward compatibility.
I think you should open an FR for this in the FreeCAD-addon repo so it doesn't get lost
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
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: check workbench update with AddonManager

Post by yorik »

In git commit 0f714e00f1 there is now a function that you can use to check if a certain addon has an update available:

Code: Select all

def myCallbackFunction(result):
    if result == "True":
        print("A new version is available for addon XXX! Go get it!")
        # do whatever you want here, show a dialog, flash a button, etc
   else:
        print("no update available")

import AddonManager
AddonManager.check_updates("MyAddonName",myCallbackFunction)
About @TheMarkster's idea, that's what I want to do as well, but wasn't too sure of the implications of connecting and doing GIT stuff in the background while FreeCAD starts. So I implemented it locally first (in the BIM WB, and inside the AddonManager, if the appropriate option is turned on in the config screen). So far it seems to work without problems, though
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: check workbench update with AddonManager

Post by TheMarkster »

Nice.

What is the preferred way to check if this feature is available?

Code: Select all

if hasattr(AddonManager, "check_updates"):
or is there a way to check by version number? We could use the FreeCAD version information, but it could come to pass at some point AddonManager is able to update itself, which would decouple it from the FreeCAD version number.

Also, if check_updates gets expanded, perhaps to support macros from the wiki or whatever, then this above method doesn't differentiate. Is there a way to get AddonManager version number? Or would there be an even better way to check this new API for supported capabilities where we could query it with something like:

Code: Select all

if "macro_updating" in AddonManager.supported_functions():
Post Reply