app_update.extract_restart() doesnt actually overwrite the version?
Closed this issue · 2 comments
Hi Everyone, I have been trying to figure out this issue for a couple days now where I have a button in which upon its clicked, the check_for_update() function is called and it displays whether a new update is available or not using PyQt5 as my GUI. My current code just restarts the executable without actually updating the version to the newest since as I press update it keeps on restarting the executable. Would greatly appreciate if someone could be of help.
Using localhost/8000 for grabbing updates
Windows 64 bit
Python 3.9.5 32-bit Interpreter
Update.py:
from client_config import ClientConfig
from pyupdater.client import Client, AppUpdate
def check_for_update():
client = Client(ClientConfig(), refresh=True)
app_update = client.update_check(ClientConfig.APP_NAME, ClientConfig.APP_VERSION)
if app_update is not None: # is there a new update
if app_update.download(): # the update download is made here
if isinstance(app_update, AppUpdate): # you should freeze it
app_update.extract_restart()
return True
else:
app_update.extract()
return True
return False
Qtwindow.py:
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLabel
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot
from update import check_for_update
from client_config import ClientConfig
import logging
from pyupdater.client import get_highest_version
class App(QWidget):
def __init__(self):
super().__init__()
self.title = f'Auto-Updater Example Version - {ClientConfig.APP_VERSION}'
self.left = 100
self.top = 100
self.width = 320
self.height = 200
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.labl = QLabel(self)
button = QPushButton('Update', self)
button.setToolTip('Click me!')
button.move(100,70)
button.clicked.connect(self.on_click)
self.show()
@pyqtSlot()
def on_click(self):
if check_for_update():
self.labl.setText('There\'s a new update :D')
self.labl.adjustSize()
else:
self.labl.setText('Sorry no updates for you :P')
self.labl.adjustSize()
# logger = logging.getLogger(__name__)
# logger.setLevel(logging.DEBUG)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec_())
@JMSwag Would highly appreciate it if I could get your input on this
Hi! Did you ever get this working? I am struggling with something similar myself.