0

I keep getting: AttributeError: 'NoneType' object has no attribute 'is_downloaded'. I am trying to integrate pyupdater with an executable. My amazon folder contains: pyu_test-win-1.0.zip and versions.gz which I upload.

Error:
{}
{}
nothing new
Traceback (most recent call last):
  File "C:/Users/D1/Desktop/31/pyu_test.py", line 25, in <module>
    if app_update.is_downloaded():
AttributeError: 'NoneType' object has no attribute 'is_downloaded'

Process finished with exit code 1

I'm getting also unresolved reference client_config as well as ClientConfig is underlined when I hover.

This is for: pyu_test.py

from pyupdater.client import Client
from client_config import ClientConfig

APP_NAME = 'pyu_test'
APP_VERSION = '1.0'

def print_status_info(info):
    total = info.get(u'total')
    downloaded = info.get(u'downloaded')
    status = info.get(u'status')
    print (downloaded, total, status)


client = Client(ClientConfig(), refresh=True,
                        progress_hooks=[print_status_info])


app_update = client.update_check(APP_NAME, APP_VERSION)

if app_update is not None:
    app_update.download()
else:
    print("nothing new")

if app_update.is_downloaded():
    app_update.extract_overwrite()

client_config

class ClientConfig(object):
    PUBLIC_KEY = '+WDWADADAWDADDWDW'
    APP_NAME = 'pyu_test'
    COMPANY_NAME = 'pyu_test'
    UPDATE_URLS = ['https://console.aws.amazon.com/s3/buckets/xWAXWED/?region=us-east-2&tab=overview']
    MAX_DOWNLOAD_RETRIES = 3

Any ideas how I can address this. Cheers.

  • Your issue is that `app_update` can be `None` sometimes. You check this before calling `.download()` (which is the safe thing to do), but not before calling `.is_downloaded()`, which is unsafe, and will result in the error you have if `app_update is None`. – Mark Nov 27 '17 at 05:07
  • @Mark Well changing it to if app_update is None: results in same issue so I'm not sure if this is the reason –  Nov 27 '17 at 05:10
  • @VanPeer is it not checking against (APP_NAME, APP_VERSION) -> APP_NAME = 'pyu_test' APP_VERSION = '0.1.0' earlier in code? Hmm.. –  Nov 27 '17 at 05:11
  • Does this answer your question? [Why do I get AttributeError: 'NoneType' object has no attribute 'something'?](https://stackoverflow.com/questions/8949252/why-do-i-get-attributeerror-nonetype-object-has-no-attribute-something) – Ulrich Eckhardt Jan 05 '22 at 18:10

1 Answers1

0

Depending on precisely what .download() does, the following may work:

app_update = client.update_check(APP_NAME, APP_VERSION)

if app_update is not None:
    app_update.download()
    app_update.extract_overwrite()
else:
    print("App Update not downloaded")

Regardless of what it does, the following is a "safe" version of your code, that will no longer have the particular type error.

app_update = client.update_check(APP_NAME, APP_VERSION)

if app_update is not None:
    app_update.download()
else:
    print("nothing new")

if app_update is not None and app_update.is_downloaded():
    app_update.extract_overwrite()

Note that this second if statement has to be written in this order, and:

if app_update.is_downloaded() and app_update is not None:

will result in potential errors, due to how Python evaluates these sorts of expressions.

Without knowing more of what your code is doing precisely, I can't go into further detail about what the best practice change to make would be.

Mark
  • 324
  • 3
  • 9
  • This has removed the error, though nothing seems to be downloaded from amazon so it prints "nothing new" –  Nov 27 '17 at 05:27
  • AttributeError: 'NoneType' object has no attribute 'download' –  Nov 27 '17 at 05:33
  • @TysonDogerzonda your error appears to be non-trivial. Looking into it a bit via `pdb`, it appears that `self.ready = False` erroneously during the execution of `update_check` (and therefore `_update_check`) --- see line 240 [here](https://github.com/JMSwag/PyUpdater/blob/master/pyupdater/client/__init__.py) in the source of pyupdater. Calling `client.refresh()` beforehand points towards an issue in `_get_key_data` at line 433. Specifically, at line 441 an `IOError` is raised trying to unzip the gziped file. At this point, chasing the bug seems like too much work. Hopefully this helps – Mark Nov 27 '17 at 05:53
  • If I had to guess the error, it would be with `self.update_urls` – Mark Nov 27 '17 at 06:02
  • Additionally, it may be useful to run `pyupdater collect-debug-info`, and link the output of that here. This question appears to be specific to `pyupdater` now though, which I have no experience with, so I'll bow out. – Mark Nov 27 '17 at 06:06