Closed LorenzoAlfaro closed 8 months ago
Hi @LorenzoAlfaro , thanks for your interest in tufup. :-)
It is certainly possible to restart your app after the update has finished.
The way to approach this depends on your platform, and on the way your app is bundled (e.g. if you're using PyInstaller):
On Windows, this could be done by supplying a custom batch-file template, as described in tufup #48. I haven't tested this specific case yet, but here's what the batch template could look like:
custom_batch_template = """@echo off
{log_lines}
echo Moving app files...
robocopy "{src_dir}" "{dst_dir}" {robocopy_options}
echo Done.
echo Restarting app
start "" "{app_exe_path}"
{delete_self}
"""
This adds a line to the default template, using the windows start
command to restart the app.
Note that the template introduces a custom template variable called app_exe_path
. Both custom variables need to be passed on to the client (also see tufup #48):
client.download_and_install_update(
...,
batch_template=custom_batch_template,
batch_template_extra_kwargs=dict(app_exe_path=...),
...,
)
The value of app_exe_path
depends on your bundle. For example, if you're using a PyInstaller bundle, you could use sys.executable
, or if you're running a plain python script, you could perhaps use something like f'{sys.executable}\" \"{sys.argv[0]}'
. Have a look at this explanation as well.
As mentioned above, I haven't tested this specific example yet, but I hope the general idea is clear.
@LorenzoAlfaro Please let us know if you run into any issues. :-)
Hi Dennis, thank you for taking the time for such a complete answer. With your help I managed to make it work!
Hi @LorenzoAlfaro Good to hear it's working. Thanks for your feedback. :-)
This is awesome stuff, I that recommend you include it in the tufup documentation.
Hello guys, I have an existing python application could you please guide me how to integrate tufup in that? also I'm using a Linux as repository to push updates.
so i want to achieve this, I push the new updated application files on server, the old app should fetch new updates from there and update the app.
please help me out, I'm unable to do it on my own. your help will be appreciated. thanks
@mdhuzaifapatel see https://github.com/dennisvang/tufup-example/issues/3#issuecomment-1698822223
Hi, is there a way to separate the client from the main app so the client will update the app and then run it after the update? The way the example is set up after an update, the app has to close itself, and then you have to rerun the app manually. I'm just thinking of ways to reduce friction for the end user.