Pyupdater Client.refresh() is not working

Question:

When I try to create a client from Pyupdater, I get the following error. I also created and imported the keys since the error seems to point that _get_signing_key() is None.

Traceback (most recent call last): File "setup.py", line 65, in

status = CheckForUpdates()   File "setup.py", line 31, in CheckForUpdates

client = Client(ClientConfig(), refresh=True)   File "C:UsersuserAppDataLocalProgramsPythonPython37-32libsite-packagespyupdaterclient__init__.py", line 213, in __init__

self.refresh()   File "C:UsersuserAppDataLocalProgramsPythonPython37-32libsite-packagespyupdaterclient__init__.py", line 217, in refresh

self._get_signing_key()   File "C:UsersuserAppDataLocalProgramsPythonPython37-32libsite-packagespyupdaterclient__init__.py", line 368, in _get_signing_key

key_data = json.loads(key_data_str.decode("utf-8"))   File "C:UsersuserAppDataLocalProgramsPythonPython37-32libjson__init__.py", line 348, in loads

return _default_decoder.decode(s)   File "C:UsersuserAppDataLocalProgramsPythonPython37-32libjsondecoder.py", line 337, in decode

obj, end = self.raw_decode(s, idx=_w(s, 0).end())   File "C:UsersuserAppDataLocalProgramsPythonPython37-32libjsondecoder.py", line 355, in raw_decode

raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This is the following code.

import sys
from client_config import ClientConfig
from pyupdater.client import Client
from progressbar import ProgressBar, Percentage, Bar
import warnings
from dotenv import load_dotenv, find_dotenv
import os

BASEDIR = os.path.abspath(os.path.dirname(__file__))
load_dotenv(find_dotenv())

warnings.filterwarnings("ignore")

__version__ = "1.0"
bar = None


def CheckForUpdates():
    """
    Check for updates.
    Channel options are stable, beta & alpha
    Patches are only created & applied on the stable channel
    """
    def cb(status):
        global bar

        if bar is None:
            bar = ProgressBar(widgets=[Percentage(), Bar()], fd=sys.stdout).start()
        zz = float(status['percent_complete'])

        bar.update(zz)
    
    CLIENT_CFG = ClientConfig()
    client = Client(ClientConfig(), refresh=True)
    
    print("Current Version: ",__version__)
    #logger.info('Checkung for updates')
    appUpdate = client.update_check(CLIENT_CFG.APP_NAME,
                                    __version__,
                                    channel='stable') # alpha, beta
    
    print("Checking for updates...")
    if appUpdate:
        if appUpdate.latest > appUpdate.current_version:
            check = input("New Update available. Do you want to install the update?(y/n)")
        if hasattr(sys, "frozen") and check=="y":
            appUpdate.progress_hooks.append(cb)
            downloaded = appUpdate.download()
            if downloaded:
                check = input("Do you want to restart the application now?(y/n)")
                if check == "y":
                    status = 'Extracting update and restarting.'
                    appUpdate.extract_restart()
                else:
                    status = 'Update download failed. Try again later'
            else:
                status = 'Update download failed. Try again later'
        elif check=="n":
            status = 'Update download failed. Try again later'
        else:
            status = f'Update available with version {appUpdate.version} but application is not frozen.'
    else:
        status = 'No available updates were found.'

    return status

Pyupdater and pyinstaller versions:

python==3.7.9

pip==22.1

Pyupdater==4.0

pyinstaller==5.1

Asked By: ewowza18

||

Answers:

Unfortunately, PyUpdater 4.0 is broken. See PyUpdater issue 320.

Some options:

  • downgrade to PyUpdater 3.1.1.
  • wait until PR 322 is accepted (or install directly from the fork)
  • wait for PyUpdater 5.x
  • try an alternative, e.g. our tufup (TUF-updater)

Update:

Its seems PyUpdater is now officially archived, so there won’t be any new releases there.

Answered By: djvg
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.