[Bf-extensions-cvs] [6f7c4230] master: BlenderKit: fix T70890

Vilém Duha noreply at git.blender.org
Sun Jul 12 19:17:08 CEST 2020


Commit: 6f7c4230af8e404d9fa9687b80ee8e7f3f8eac1d
Author: Vilém Duha
Date:   Thu Jul 9 09:00:56 2020 +0200
Branches: master
https://developer.blender.org/rBA6f7c4230af8e404d9fa9687b80ee8e7f3f8eac1d

BlenderKit: fix T70890

this is a complex fix that required to change some basic behaviours.
- the temp folder from blenderkit_data was moved to system temp folder
- There's a cleanup function for the old folder.
- search itself doesn't create files on drive(this rework will continue to try not to write also some other data, like gravatars, but cache them in mem only)

further fixes:
 - assetbar woudln't draw if there wasn't a thumbnail in an asset
 - categories panel poll function was fixed for brushes
 - fetching tokens from rerequests wasn't writing them into prefs

 TODO: create a popup that asks if categories can be downloaded and an example search can be performed.

===================================================================

M	blenderkit/__init__.py
M	blenderkit/bkit_oauth.py
M	blenderkit/data/categories.json
M	blenderkit/paths.py
M	blenderkit/rerequests.py
M	blenderkit/search.py
M	blenderkit/ui.py
M	blenderkit/ui_panels.py
M	blenderkit/utils.py

===================================================================

diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index d511bbf8..15dcaffb 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -19,8 +19,8 @@
 bl_info = {
     "name": "BlenderKit Online Asset Library",
     "author": "Vilem Duha, Petr Dlouhy",
-    "version": (1, 0, 30),
-    "blender": (2, 82, 0),
+    "version": (1, 0, 31),
+    "blender": (2, 83, 0),
     "location": "View3D > Properties > BlenderKit",
     "description": "Online BlenderKit library (materials, models, brushes and more). Connects to the internet.",
     "warning": "",
@@ -249,17 +249,24 @@ def switch_search_results(self, context):
         s['search results orig'] = s.get('bkit brush search orig')
     search.load_previews()
 
+#define these static
+# asset_type_ui_items = (
+#             ('MODEL', 'Models', 'Find upload models in the BlenderKit online database', 'OBJECT_DATAMODE',0),
+#             # ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
+#             ('MATERIAL', 'Materials', 'Find or upload models in the BlenderKit online database', 'MATERIAL',2),
+#             # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
+#             ('BRUSH', 'Brushes', 'Find or upload models in the BlenderKit online database', 'BRUSH_DATA',3)
+#         )
 
+#same as above, but dynamic.
 def asset_type_callback(self, context):
-    # s = bpy.context.scene
-    # ui_props = s.blenderkitUI
     if self.down_up == 'SEARCH':
         items = (
             ('MODEL', 'Models', 'Find models in the BlenderKit online database', 'OBJECT_DATAMODE', 0),
             # ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
-            ('MATERIAL', 'Materials', 'Find models in the BlenderKit online database', 'MATERIAL', 2),
+            ('MATERIAL', 'Materials', 'Find materials in the BlenderKit online database', 'MATERIAL', 2),
             # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
-            ('BRUSH', 'Brushes', 'Find models in the BlenderKit online database', 'BRUSH_DATA', 3)
+            ('BRUSH', 'Brushes', 'Find brushes in the BlenderKit online database', 'BRUSH_DATA', 3)
         )
     else:
         items = (
diff --git a/blenderkit/bkit_oauth.py b/blenderkit/bkit_oauth.py
index 4d2f09dc..0bf20d4a 100644
--- a/blenderkit/bkit_oauth.py
+++ b/blenderkit/bkit_oauth.py
@@ -70,7 +70,7 @@ def refresh_token_thread():
         thread = threading.Thread(target=refresh_token, args=([preferences.api_key_refresh, url]), daemon=True)
         thread.start()
     else:
-        ui.add_report('Already Refreshing token, will be ready soon.')
+        ui.add_report('Already Refreshing token, will be ready soon. If this fails, please login again in Login panel.')
 
 
 def refresh_token(api_key_refresh, url):
@@ -139,7 +139,8 @@ class Logout(bpy.types.Operator):
         preferences.login_attempt = False
         preferences.api_key_refresh = ''
         preferences.api_key = ''
-        del (bpy.context.window_manager['bkit profile'])
+        if bpy.context.window_manager.get('bkit profile'):
+            del (bpy.context.window_manager['bkit profile'])
         return {'FINISHED'}
 
 
diff --git a/blenderkit/data/categories.json b/blenderkit/data/categories.json
index 2eb34a34..d6286050 100644
--- a/blenderkit/data/categories.json
+++ b/blenderkit/data/categories.json
@@ -1,21 +1,4 @@
 [
-    {
-        "name": "addon",
-        "slug": "addon",
-        "active": true,
-        "thumbnail": null,
-        "thumbnailWidth": null,
-        "thumbnailHeight": null,
-        "order": 0,
-        "alternateTitle": "addon",
-        "alternateUrl": "",
-        "description": "",
-        "metaKeywords": "",
-        "metaExtra": "",
-        "children": [],
-        "assetCount": 3,
-        "assetCountCumulative": 3
-    },
     {
         "name": "brush",
         "slug": "brush",
@@ -98,23 +81,6 @@
                 "assetCount": 8,
                 "assetCountCumulative": 8
             },
-            {
-                "name": "crack",
-                "slug": "crack",
-                "active": true,
-                "thumbnail": null,
-                "thumbnailWidth": null,
-                "thumbnailHeight": null,
-                "order": 0,
-                "alternateTitle": "crack",
-                "alternateUrl": "",
-                "description": "",
-                "metaKeywords": "",
-                "metaExtra": "",
-                "children": [],
-                "assetCount": 0,
-                "assetCountCumulative": 0
-            },
             {
                 "name": "cut",
                 "slug": "cut",
@@ -268,23 +234,6 @@
                 "assetCount": 1,
                 "assetCountCumulative": 1
             },
-            {
-                "name": "nature",
-                "slug": "nature-brush",
-                "active": true,
-                "thumbnail": null,
-                "thumbnailWidth": null,
-                "thumbnailHeight": null,
-                "order": 0,
-                "alternateTitle": "nature",
-                "alternateUrl": "",
-                "description": "",
-                "metaKeywords": "",
-                "metaExtra": "",
-                "children": [],
-                "assetCount": 1,
-                "assetCountCumulative": 1
-            },
             {
                 "name": "pattern",
                 "slug": "pattern",
@@ -316,42 +265,8 @@
                 "metaKeywords": "",
                 "metaExtra": "",
                 "children": [],
-                "assetCount": 7,
-                "assetCountCumulative": 7
-            },
-            {
-                "name": "rust",
-                "slug": "rust-brush",
-                "active": true,
-                "thumbnail": null,
-                "thumbnailWidth": null,
-                "thumbnailHeight": null,
-                "order": 0,
-                "alternateTitle": "rust",
-                "alternateUrl": "",
-                "description": "",
-                "metaKeywords": "",
-                "metaExtra": "",
-                "children": [],
-                "assetCount": 0,
-                "assetCountCumulative": 0
-            },
-            {
-                "name": "sculpture",
-                "slug": "sculpture-brush",
-                "active": true,
-                "thumbnail": null,
-                "thumbnailWidth": null,
-                "thumbnailHeight": null,
-                "order": 0,
-                "alternateTitle": "sculpture",
-                "alternateUrl": "",
-                "description": "",
-                "metaKeywords": "",
-                "metaExtra": "",
-                "children": [],
-                "assetCount": 0,
-                "assetCountCumulative": 0
+                "assetCount": 8,
+                "assetCountCumulative": 8
             },
             {
                 "name": "stitches",
@@ -370,23 +285,6 @@
                 "assetCount": 12,
                 "assetCountCumulative": 12
             },
-            {
-                "name": "stone",
-                "slug": "stone-brush",
-                "active": true,
-                "thumbnail": null,
-                "thumbnailWidth": null,
-                "thumbnailHeight": null,
-                "order": 0,
-                "alternateTitle": "stone",
-                "alternateUrl": "",
-                "description": "",
-                "metaKeywords": "",
-                "metaExtra": "",
-                "children": [],
-                "assetCount": 0,
-                "assetCountCumulative": 0
-            },
             {
                 "name": "tree",
                 "slug": "tree-brush",
@@ -403,23 +301,6 @@
                 "children": [],
                 "assetCount": 4,
                 "assetCountCumulative": 4
-            },
-            {
-                "name": "wood",
-                "slug": "wood-brush",
-                "active": true,
-                "thumbnail": null,
-                "thumbnailWidth": null,
-                "thumbnailHeight": null,
-                "order": 0,
-                "alternateTitle": "wood",
-                "alternateUrl": "",
-                "description": "",
-                "metaKeywords": "",
-                "metaExtra": "",
-                "children": [],
-                "assetCount": 0,
-                "assetCountCumulative": 0
             }
         ],
         "assetCount": 94,
@@ -453,8 +334,8 @@
                 "metaKeywords": "",
                 "metaExtra": "",
                 "children": [],
-                "assetCount": 2,
-                "assetCountCumulative": 2
+                "assetCount": 36,
+                "assetCountCumulative": 36
             },
             {
                 "name": "asphalt",
@@ -470,8 +351,8 @@
                 "metaKeywords": "",
                 "metaExtra": "",
                 "children": [],
-                "assetCount": 5,
-                "assetCountCumulative": 5
+                "assetCount": 36,
+                "assetCountCumulative": 36
             },
             {
                 "name": "bricks",
@@ -487,8 +368,8 @@
                 "metaKeywords": "",
                 "metaExtra": "",
                 "children": [],
-                "assetCount": 10,
-                "assetCountCumulative": 10
+                "assetCount": 64,
+                "assetCountCumulative": 64
             },
             {
                 "name": "ceramic",
@@ -504,8 +385,8 @@
                 "metaKeywords": "",
                 "metaExtra": "",
                 "children": [],
-                "assetCount": 2,
-                "assetCountCumulative": 2
+                "assetCount": 16,
+                "assetCountCumulative": 16
             },
             {
                 "name": "concrete",
@@ -521,8 +402,8 @@
                 "metaKeywords": "",
                 "metaExtra": "",
                 "children": [],
-                "assetCount": 21,
-                "assetCountCumulative": 21
+                "assetCount": 64,
+                "assetCountCumulative": 64
             },
             {
                 "name": "dirt",
@@ -538,8 +419,8 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list