我一直得到:AttributeError:' NoneType'对象没有属性' is_downloaded'。我正在尝试将pyupdater与可执行文件集成。我的amazon文件夹包含: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
我有什么想法可以解决这个问题。欢呼声。
答案 0 :(得分:0)
具体取决于.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")
无论它做什么,以下是代码的“安全”版本,不再具有特定类型错误。
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如何评估这些表达式,将导致潜在的错误。
在不了解您的代码正在做什么的更多内容的情况下,我无法进一步详细了解最佳实践的变化。