XOYZ69 / school_reports

Generate custom reports for your school based on a .json file
0 stars 0 forks source link

Implement Auto-Updater #14

Open Prixix opened 3 weeks ago

Prixix commented 3 weeks ago

Is your feature request related to a problem? Please describe. Having an auto updater will have positive impact on usability and would make the program easier to use. Known bugs can be fixed directly without the need of manual updating.

Describe the solution you'd like I would like the script to automatically check for updates from the GitHub repository, download the latest version if available, and replace the old script with the new one. This should happen seamlessly without user intervention, and the script should restart itself after updating to ensure the latest version is running.

Describe alternatives you've considered

Additional context I created a mock up script, which will check for the latest release on GitHub.

import os
import sys
import requests

def get_latest_version(repo):
    url = f"https://api.github.com/repos/{repo}/releases/latest"
    response = requests.get(url)
    data = response.json()
    return data['tag_name']

def get_current_version():
    return "1.0.0"  # replace with current version

def check_for_update(repo):
    current_version = get_current_version()
    latest_version = get_latest_version(repo)
    return latest_version > current_version

def download_latest_release(repo):
    # add logic

repo = "XOYZ69/school_reports" 
if check_for_update(repo):
    # add logic
else:
    # run program

It might be that we need to download the full tar ball / zip and pushing it into the current directory, but the config and the reports.json, will be deleted each update. So a possibile solution would be to back up those files in a temporary folder and pushing it back to the directory, when the update is finished.

XOYZ69 commented 3 weeks ago

Yep very good and needed. Since we have 2 ways of running the program I think there should be 2 ways of handling updates.

Console Varaint If the script is ran, it automatically checks for updates if a network connection is available and notifies the user to update. Much like the pip updating works for Python.

GUI Variant If you open the GUI an a new version is available you should see a Popup with the new version and the changelog summary as well as 3 Buttons for yes, no and skip this release.


That would be my first idea how to handle this. What do you think?

Prixix commented 3 weeks ago

Console Variant So before building a message should pop up?

1.0.0 -> 1.1.0 
An update is available, would you like to install the update? [y]es | [n]o | [i]gnore

GUI Variant Basically like in the cli version. But updating should work the same way as the cli version to prevent duplication.

XOYZ69 commented 3 weeks ago

Console Variant So before building a message should pop up?


1.0.0 -> 1.1.0 
An update is available, would you like to install the update? [y]es | [n]o | [i]gnore

Not quite I would like to have it like this: An update is available. Run python setup.py -u to update.

GUI Variant Basically like in the cli version. But updating should work the same way as the cli version to prevent duplication.

In the GUI there would then be a popup with yes, no, ignore. This would be the best approach probably since if we add a user input request into the console it could break automation. Or we need a parameter like -mode handsfree which ignores all user input requests.

Prixix commented 3 weeks ago

Not quite I would like to have it like this: An update is available. Run python setup.py -u to update.

Okay that would be fine too.

Or we need a parameter like -mode handsfree which ignores all user input requests.

That would be the best solution, I think.