AppImage - Include auto-updating logic in to appimage directly?

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: AppImage - Include auto-updating logic in to appimage directly?

Post by Kunda1 »

antonyjr wrote: Sun Mar 22, 2020 4:10 pm
looo wrote: Sun Mar 22, 2020 6:36 am Any chance to add the plugin logic to cmake? qmake is a pain with conda-build (at least for me).
@looo sure I can. Just wait a bit, I will release all the documentation and also the instruction to build the plugin with cmake ASAP.
Thank you, both!
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
antonyjr
Posts: 45
Joined: Sat Mar 21, 2020 9:35 pm
Contact:

Re: AppImage - Include auto-updating logic in to appimage directly?

Post by antonyjr »

Using AppImageUpdaterBridge as Plugin,
That's all you need to know to use the plugin with python. You can use v1.1.7 if you want to use the plugin.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: AppImage - Include auto-updating logic in to appimage directly?

Post by looo »

antonyjr wrote: Sat Mar 28, 2020 8:47 pm Using AppImageUpdaterBridge as Plugin,
That's all you need to know to use the plugin with python. You can use v1.1.7 if you want to use the plugin.
nice! I will include the package in the next appimage so we can try to update the appimage from within freecad.

Code: Select all

import sys
import os
from PySide.QtCore import QPluginLoader


def handleUpdate(avail, info):
    if avail:
        print("New Update Available!")
    else:
        print("You have the latest version!")


def update_appimage():
    path = os.path.join(os.environ["PREFIX"],
                        "lib", "libAppImageUpdaterBridge.so")
    loader = QPluginLoader()
    loader.setFileName(path)
    loader.load()
    AppImageUpdaterBridge = loader.instance()

    AppImageUpdaterBridge.updateAvailable.connect(handleUpdate)
    AppImageUpdaterBridge.setAppImage(os.environ["APPIMAGE"])
    AppImageUpdaterBridge.checkForUpdate()


update_appimage()

User avatar
antonyjr
Posts: 45
Joined: Sat Mar 21, 2020 9:35 pm
Contact:

Re: AppImage - Include auto-updating logic in to appimage directly?

Post by antonyjr »

@looo you really don't need the absolute path if you move the plugin to PySide's default plugin directory. Also you don't need to give the AppImage path if you execute from a AppImage since the plugin itself will guess the AppImage path from the environmental variable.

So the code can be reduced as following,

Code: Select all

from PySide.QtCore import QPluginLoader


def handleUpdate(avail, info):
    if avail:
        print("New Update Available!")
    else:
        print("You have the latest version!")


def update_appimage():
    loader = QPluginLoader()
    # Just make sure it is present in PySide's default Plugin directory, if not present do not use the
    # internal updater, That's the key to the plugin architecture.
    loader.setFileName('libAppImageUpdaterBridge')
    if loader.load():
       AppImageUpdaterBridge = loader.instance()
       AppImageUpdaterBridge.updateAvailable.connect(handleUpdate)
       AppImageUpdaterBridge.checkForUpdate()
    else:
       print("No updater plugin found.")

update_appimage()
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: AppImage - Include auto-updating logic in to appimage directly?

Post by looo »

antonyjr wrote: Sun Mar 29, 2020 9:36 am @looo you really don't need the absolute path if you move the plugin to PySide's default plugin directory. Also you don't need to give the AppImage path if you execute from a AppImage since the plugin itself will guess the AppImage path from the environmental variable.
I am not sure what the default plugin-dirs for the freecad-appimage is. But using the relative path to the plugin-library doesn't work for me. The library itself is installed in the default lib-dir which in my case is:

'/tmp/.mount_FreeCAnCUknh/usr/lib/libAppImageUpdaterBridge.so'

Maybe we have to setup the plugin dirs in qt.conf?
https://github.com/FreeCAD/FreeCAD-AppI ... ev/qt.conf
User avatar
antonyjr
Posts: 45
Joined: Sat Mar 21, 2020 9:35 pm
Contact:

Re: AppImage - Include auto-updating logic in to appimage directly?

Post by antonyjr »

No we don't need to touch qt.conf, I think I must instruct cmake to install the plugin into qt's plugin dir when installed. I will look into it.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: AppImage - Include auto-updating logic in to appimage directly?

Post by looo »

antonyjr wrote: Sun Mar 29, 2020 2:03 pm No we don't need to touch qt.conf, I think I must instruct cmake to install the plugin into qt's plugin dir when installed. I will look into it.
I guess by setting "-D CMAKE_INSTALL_LIBDIR:FILEPATH=$PREFIX/plugins \" the plugin should be installed correctly. But now when trying to update the appimage I don't see any feedback. So I think something does not work correctly.
User avatar
antonyjr
Posts: 45
Joined: Sat Mar 21, 2020 9:35 pm
Contact:

Re: AppImage - Include auto-updating logic in to appimage directly?

Post by antonyjr »

looo wrote: Sun Apr 12, 2020 9:42 am
antonyjr wrote: Sun Mar 29, 2020 2:03 pm No we don't need to touch qt.conf, I think I must instruct cmake to install the plugin into qt's plugin dir when installed. I will look into it.
I guess by setting "-D CMAKE_INSTALL_LIBDIR:FILEPATH=$PREFIX/plugins \" the plugin should be installed correctly. But now when trying to update the appimage I don't see any feedback. So I think something does not work correctly.
The updater only starts working after you start the Qt's event loop (i.e you have to create the QApplication object) so you can't test this in an interactive python session, This is to ensure safety. This is how the library is non-blocking and single threaded. Sorry for the very late reply. I really don't know how to proceed with this issue. Are we implementing the updater from the menu???
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: AppImage - Include auto-updating logic in to appimage directly?

Post by looo »

antonyjr wrote: Thu May 14, 2020 11:30 am The updater only starts working after you start the Qt's event loop (i.e you have to create the QApplication object) so you can't test this in an interactive python session, This is to ensure safety. This is how the library is non-blocking and single threaded.
I tried to update from the FreeCAD console, so the qtapplication was already started.
User avatar
antonyjr
Posts: 45
Joined: Sat Mar 21, 2020 9:35 pm
Contact:

Re: AppImage - Include auto-updating logic in to appimage directly?

Post by antonyjr »

I will try this on my machine.
Post Reply