Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilem Duha <vilem.duha@gmail.com>2019-04-20 13:45:38 +0300
committerVilem Duha <vilem.duha@gmail.com>2019-04-21 22:20:16 +0300
commitd7e9c0f2047e139c7e2e19b5c95f5e59f92caada (patch)
treeaf853c9ad5d2165c3661d1c9b0ecbd7750699f85 /blenderkit
parentec308bd6d6b21c4c31be6b9ada2571ba0aec2bdb (diff)
BlenderKit: Don't run blenderkit checks when running in background
Diffstat (limited to 'blenderkit')
-rw-r--r--blenderkit/download.py5
-rw-r--r--blenderkit/utils.py41
2 files changed, 24 insertions, 22 deletions
diff --git a/blenderkit/download.py b/blenderkit/download.py
index 65dc631b..c1db12ea 100644
--- a/blenderkit/download.py
+++ b/blenderkit/download.py
@@ -106,8 +106,9 @@ def check_unused():
def scene_save(context):
''' does cleanup of blenderkit props and sends a message to the server about assets used.'''
# TODO this can be optimized by merging these 2 functions, since both iterate over all objects.
- check_unused()
- report_usages()
+ if not bpy.app.background:
+ check_unused()
+ report_usages()
@persistent
diff --git a/blenderkit/utils.py b/blenderkit/utils.py
index 336b4ab1..2c12f0e7 100644
--- a/blenderkit/utils.py
+++ b/blenderkit/utils.py
@@ -175,26 +175,27 @@ def load_prefs():
user_preferences.global_dir = prefs['global_dir']
def save_prefs(self, context):
- user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
- if user_preferences.api_key != '':
- print(len(user_preferences.api_key))
- print('length')
- if len(user_preferences.api_key)>35:
- prefs = {
- 'API_key': user_preferences.api_key,
- 'global_dir': user_preferences.global_dir,
- }
- # user_preferences.api_key = user_preferences.api_key.strip()
- fpath = paths.BLENDERKIT_SETTINGS_FILENAME
- f = open(fpath, 'w')
- with open(fpath, 'w') as s:
- json.dump(prefs, s)
- bpy.ops.wm.save_userpref()
- else:
- # reset the api key in case the user writes some nonsense, e.g. a search string instead of the Key
- user_preferences.api_key = ''
- props = get_search_props()
- props.report = 'Please paste a correct API Key.'
+ if not bpy.app.background:
+ user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
+ if user_preferences.api_key != '':
+ print(len(user_preferences.api_key))
+ print('length')
+ if len(user_preferences.api_key)>35:
+ prefs = {
+ 'API_key': user_preferences.api_key,
+ 'global_dir': user_preferences.global_dir,
+ }
+ # user_preferences.api_key = user_preferences.api_key.strip()
+ fpath = paths.BLENDERKIT_SETTINGS_FILENAME
+ f = open(fpath, 'w')
+ with open(fpath, 'w') as s:
+ json.dump(prefs, s)
+ bpy.ops.wm.save_userpref()
+ else:
+ # reset the api key in case the user writes some nonsense, e.g. a search string instead of the Key
+ user_preferences.api_key = ''
+ props = get_search_props()
+ props.report = 'Please paste a correct API Key.'
def load_categories():
categories.copy_categories()