cloudfoundry-community / cloudfoundry-community/cf-python-client
NoneType' object has no attribute 'items'
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 55
- Fork
- 54
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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'
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với cloudfoundry_client/v2/entities.py tại _list và constructor _Application trong cloudfoundry_client/v2/apps.py, sử dụng traceback được cung cấp cùng các vòng lặp lặp lại client.v2.apps và client.v2.buildpacks làm đường dẫn tái hiện. Xác định lý do một tài nguyên được liệt kê có entity null sau 10–15 phút và thêm một regression test cho response đó; hoàn thành khi vòng lặp không còn phát sinh AttributeError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- api, backend
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100