AttributeError: 'NoneType' object has no attribute 'is_downloaded'

AttributeError: 'NoneType' object has no attribute 'is_downloaded'

我不断收到:AttributeError:'NoneType' 对象没有属性 'is_downloaded'。我正在尝试将 pyupdater 与可执行文件集成。我的亚马逊文件夹包含:pyu_test-win-1.0.zip 和我上传的 versions.gz。

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.

这是为了: 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

关于如何解决这个问题的任何想法。干杯。

具体取决于 .download() 的作用,以下可能有效:

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")

无论它做什么,以下是您的代码的 "safe" 版本,它将不再有特定类型错误。

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()

注意第二个if语句必须按这个顺序写,并且:

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

由于 Python 计算这些表达式的方式,将导致潜在的错误。

在不了解您的代码准确执行的更多信息的情况下,我无法进一步详细说明要做出的最佳实践更改是什么。