BlenderKit: fix possible error when loading preferences.
This commit is contained in:
parent
c61ff213d6
commit
7faa6b379f
|
@ -468,11 +468,11 @@ class VIEW3D_PT_blenderkit_ratings(Panel):
|
|||
layout = self.layout
|
||||
assets = ratings.get_assets_for_rating()
|
||||
if len(assets) > 0:
|
||||
layout.label(text='Help BlenderKit community')
|
||||
layout.label(text='by rating these assets:')
|
||||
utils.label_multiline(layout, text='Please help BlenderKit community by rating these assets:')
|
||||
|
||||
for a in assets:
|
||||
draw_rating_asset(self, context, asset=a)
|
||||
if a.bkit_ratings.rating_work_hours==0:
|
||||
draw_rating_asset(self, context, asset=a)
|
||||
|
||||
|
||||
def draw_login_progress(layout):
|
||||
|
|
|
@ -233,11 +233,15 @@ def load_prefs():
|
|||
# if user_preferences.api_key == '':
|
||||
fpath = paths.BLENDERKIT_SETTINGS_FILENAME
|
||||
if os.path.exists(fpath):
|
||||
with open(fpath, 'r') as s:
|
||||
prefs = json.load(s)
|
||||
user_preferences.api_key = prefs.get('API_key', '')
|
||||
user_preferences.global_dir = prefs.get('global_dir', paths.default_global_dict())
|
||||
user_preferences.api_key_refresh = prefs.get('API_key_refresh', '')
|
||||
try:
|
||||
with open(fpath, 'r') as s:
|
||||
prefs = json.load(s)
|
||||
user_preferences.api_key = prefs.get('API_key', '')
|
||||
user_preferences.global_dir = prefs.get('global_dir', paths.default_global_dict())
|
||||
user_preferences.api_key_refresh = prefs.get('API_key_refresh', '')
|
||||
except Exception as e:
|
||||
print('failed to read addon preferences.')
|
||||
print(e)
|
||||
|
||||
|
||||
def save_prefs(self, context):
|
||||
|
|
Loading…
Reference in New Issue