cloudfoundry-community / cloudfoundry-community/cf-python-client
NoneType' object has no attribute 'items'
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 55
- フォーク
- 54
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Hi There
Stumbled upon this issue when building out a flask application but have also noticed this when just testing the code in a simple consistent loop.
Looking for pointers if there is something obvious I am missing in this.
Using Username/Password to authenticate.
Error usually occurs after 10-15 mins of running without issue.
SCRIPT CODE
foundation_name = 'lab'
target_endpoint = '<URL>'
proxy = dict(http=os.environ.get('HTTP_PROXY', ''), https=os.environ.get('HTTPS_PROXY', ''))
client = CloudFoundryClient(target_endpoint, proxy=proxy, verify=False)
client.init_with_user_credentials('<USERNAME>','<PAASWORD>')
def app_buildpacks():
app_buildpack_usage = []
app_buildpack_table_field_names = ['App Name', 'Buildpack Used', ' Buildpack Stack', 'GUID', 'Filename' , 'Locked']
for app in client.v2.apps:
app_name = app['entity']['name']
app_buildpack_name = app['entity']['detected_buildpack'] or app['entity']['buildpack']
app_buildpack_guid = app['entity']['detected_buildpack_guid']
for buildpack in client.v2.buildpacks:
buildpack_guid = buildpack['metadata']['guid']
if app_buildpack_guid == buildpack_guid:
buildpack_name = buildpack['entity']['name']
buildpack_stack = buildpack['entity']['stack']
buildpack_filename = buildpack['entity']['filename']
buildpack_lock = buildpack['entity']['locked']
d = {
'app_name' : app_name ,
'buildpack_name' : buildpack_name,
'buildpack_stack' : buildpack_stack ,
'buildpack_guid' : buildpack_guid,
'buildpack_filename': buildpack_filename,
'buildpack_lock' : buildpack_lock
}
app_buildpack_usage.append(d)
# Sort the list by name
app_buildpack_usage = sorted(app_buildpack_usage, key = lambda i: i['buildpack_name'])
# Return the two values ( Builpack usage list of dicts and table headers )
return app_buildpack_usage,app_buildpack_table_field_names
def background():
global app_buildpack_usage, app_buildpack_table_field_names
while True:
try:
app_buildpack_usage,app_buildpack_table_field_names = app_buildpacks()
def foreground():
@app.route('/app_buildpacks')
def app_buildpacks_page():
return render_template('app_buildpack_table.html', colnames=app_buildpack_table_field_names, app_buildpack_usage=app_buildpack_usage)
b = threading.Thread(name='background', target=background)
f = threading.Thread(name='foreground', target=foreground)
b.start()
f.start()
ERROR
\Python37\lib\site-packages\cloudfoundry_client\v2\entities.py", line 66, in _list
yield entity_builder(list(resource.items()))
\Python37\lib\site-packages\cloudfoundry_client\v2\apps.py", line 51, in <lambda>
lambda pairs: _Application(target_endpoint, client, pairs))
\Python37\lib\site-packages\cloudfoundry_client\v2\entities.py", line 17, in __init__
for attribute, value in list(self['entity'].items()):
AttributeError: 'NoneType' object has no attribute 'items'
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
cloudfoundry_client/v2/entities.py の _list と、cloudfoundry_client/v2/apps.py の _Application コンストラクターから始め、提供された traceback と、再現手順として繰り返し実行する client.v2.apps および client.v2.buildpacks のループを使用します。なぜ一覧表示されたリソースの entity が 10~15 分後に null になるのかを特定し、そのレスポンスに対する回帰テストを追加します。完了条件は、ループが AttributeError を発生させなくなることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api, backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100