[Bf-extensions-cvs] [3d480318] master: Removed bundled brush pack
Pullusb
noreply at git.blender.org
Sun Oct 25 16:52:57 CET 2020
Commit: 3d480318fbbfe1c32372533a9aafe1d5a4617c26
Author: Pullusb
Date: Sun Oct 25 16:52:26 2020 +0100
Branches: master
https://developer.blender.org/rBA3d480318fbbfe1c32372533a9aafe1d5a4617c26
Removed bundled brush pack
Update following concern raised by Campbell Barton (https://developer.blender.org/rBA9da77e9af4cbf4d91d043c0a670b6e507531b67d)
Blend file and related ico files were removed.
Import brush pack operator was adapted so user can download and install from a public external url.
===================================================================
D greasepencil_tools/Official_GP_brush_pack_V1.blend
M greasepencil_tools/__init__.py
D greasepencil_tools/icos/tex_01.jpg
D greasepencil_tools/icos/tex_02.jpg
D greasepencil_tools/icos/tex_03.jpg
D greasepencil_tools/icos/tex_04.jpg
D greasepencil_tools/icos/tex_05.jpg
D greasepencil_tools/icos/tex_06.jpg
D greasepencil_tools/icos/tex_07.jpg
D greasepencil_tools/icos/tex_08.jpg
D greasepencil_tools/icos/tex_09.jpg
D greasepencil_tools/icos/tex_10.jpg
D greasepencil_tools/icos/tex_11.jpg
D greasepencil_tools/icos/tex_12.jpg
D greasepencil_tools/icos/tex_13.jpg
D greasepencil_tools/icos/tex_14.jpg
D greasepencil_tools/icos/tex_15.jpg
D greasepencil_tools/icos/tex_16.jpg
D greasepencil_tools/icos/tex_17.jpg
M greasepencil_tools/import_brush_pack.py
===================================================================
diff --git a/greasepencil_tools/Official_GP_brush_pack_V1.blend b/greasepencil_tools/Official_GP_brush_pack_V1.blend
deleted file mode 100644
index ca9c4205..00000000
Binary files a/greasepencil_tools/Official_GP_brush_pack_V1.blend and /dev/null differ
diff --git a/greasepencil_tools/__init__.py b/greasepencil_tools/__init__.py
index c99b30de..6891ccb9 100644
--- a/greasepencil_tools/__init__.py
+++ b/greasepencil_tools/__init__.py
@@ -21,7 +21,7 @@ bl_info = {
"name": "Grease Pencil Tools",
"description": "Extra tools for Grease Pencil",
"author": "Samuel Bernou, Antonio Vazquez, Daniel Martinez Lara, Matias Mendiola",
-"version": (1, 1, 3),
+"version": (1, 1, 5),
"blender": (2, 91, 0),
"location": "Sidebar > Grease Pencil > Grease Pencil Tools",
"warning": "",
diff --git a/greasepencil_tools/icos/tex_01.jpg b/greasepencil_tools/icos/tex_01.jpg
deleted file mode 100644
index e8f88b25..00000000
Binary files a/greasepencil_tools/icos/tex_01.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_02.jpg b/greasepencil_tools/icos/tex_02.jpg
deleted file mode 100644
index 61ee7700..00000000
Binary files a/greasepencil_tools/icos/tex_02.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_03.jpg b/greasepencil_tools/icos/tex_03.jpg
deleted file mode 100644
index 7a091d26..00000000
Binary files a/greasepencil_tools/icos/tex_03.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_04.jpg b/greasepencil_tools/icos/tex_04.jpg
deleted file mode 100644
index 880814e4..00000000
Binary files a/greasepencil_tools/icos/tex_04.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_05.jpg b/greasepencil_tools/icos/tex_05.jpg
deleted file mode 100644
index c7220c6e..00000000
Binary files a/greasepencil_tools/icos/tex_05.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_06.jpg b/greasepencil_tools/icos/tex_06.jpg
deleted file mode 100644
index 23d37141..00000000
Binary files a/greasepencil_tools/icos/tex_06.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_07.jpg b/greasepencil_tools/icos/tex_07.jpg
deleted file mode 100644
index 5e1b1cb3..00000000
Binary files a/greasepencil_tools/icos/tex_07.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_08.jpg b/greasepencil_tools/icos/tex_08.jpg
deleted file mode 100644
index 44376fdd..00000000
Binary files a/greasepencil_tools/icos/tex_08.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_09.jpg b/greasepencil_tools/icos/tex_09.jpg
deleted file mode 100644
index 45aff490..00000000
Binary files a/greasepencil_tools/icos/tex_09.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_10.jpg b/greasepencil_tools/icos/tex_10.jpg
deleted file mode 100644
index 952d18d9..00000000
Binary files a/greasepencil_tools/icos/tex_10.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_11.jpg b/greasepencil_tools/icos/tex_11.jpg
deleted file mode 100644
index 032bcd0c..00000000
Binary files a/greasepencil_tools/icos/tex_11.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_12.jpg b/greasepencil_tools/icos/tex_12.jpg
deleted file mode 100644
index 9e07a1b5..00000000
Binary files a/greasepencil_tools/icos/tex_12.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_13.jpg b/greasepencil_tools/icos/tex_13.jpg
deleted file mode 100644
index 05c89ca7..00000000
Binary files a/greasepencil_tools/icos/tex_13.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_14.jpg b/greasepencil_tools/icos/tex_14.jpg
deleted file mode 100644
index 8d36c530..00000000
Binary files a/greasepencil_tools/icos/tex_14.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_15.jpg b/greasepencil_tools/icos/tex_15.jpg
deleted file mode 100644
index b84732d2..00000000
Binary files a/greasepencil_tools/icos/tex_15.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_16.jpg b/greasepencil_tools/icos/tex_16.jpg
deleted file mode 100644
index 3ba1bc23..00000000
Binary files a/greasepencil_tools/icos/tex_16.jpg and /dev/null differ
diff --git a/greasepencil_tools/icos/tex_17.jpg b/greasepencil_tools/icos/tex_17.jpg
deleted file mode 100644
index b9751c7c..00000000
Binary files a/greasepencil_tools/icos/tex_17.jpg and /dev/null differ
diff --git a/greasepencil_tools/import_brush_pack.py b/greasepencil_tools/import_brush_pack.py
index fbeb25f1..90d186c3 100644
--- a/greasepencil_tools/import_brush_pack.py
+++ b/greasepencil_tools/import_brush_pack.py
@@ -1,35 +1,193 @@
import bpy
+import re
+import ssl
+import urllib.request
+import urllib.parse
+import zipfile
+from pathlib import Path
+
+def unzip(zip_path, extract_dir_path):
+ '''Get a zip path and a directory path to extract to'''
+ with zipfile.ZipFile(zip_path, 'r') as zip_ref:
+ zip_ref.extractall(extract_dir_path)
+
+def simple_dl_url(url, dest, fallback_url=None):
+ ## need to import urlib.request or linux module does not found 'request' using urllib directly
+ ## need to create an SSl context or linux fail returning unverified ssl
+ # ssl._create_default_https_context = ssl._create_unverified_context
+
+ try:
+ urllib.request.urlretrieve(url, dest)
+ except Exception as e:
+ print('Error trying to download\n', e)
+ if fallback_url:
+ print('\nDownload page for manual install:', fallback_url)
+ return e
+
+def download_url(url, dest):
+ '''download passed url to dest file (include filename)'''
+ import shutil
+ import time
+ ssl._create_default_https_context = ssl._create_unverified_context
+ start_time = time.time()
+
+ try:
+ with urllib.request.urlopen(url) as response, open(dest, 'wb') as out_file:
+ shutil.copyfileobj(response, out_file)
+ except Exception as e:
+ print('Error trying to download\n', e)
+ return e
+
+ print(f"Download time {time.time() - start_time:.2f}s",)
+
+
+def get_brushes(blend_fp):
+ cur_brushes = [b.name for b in bpy.data.brushes]
+ with bpy.data.libraries.load(str(blend_fp), link=False) as (data_from, data_to):
+ # load brushes starting with 'tex' prefix if there are not already there
+ data_to.brushes = [b for b in data_from.brushes if b.startswith('tex_') and not b in cur_brushes]
+ # Add holdout
+ if 'z_holdout' in data_from.brushes and not 'z_holdout' in cur_brushes:
+ data_to.brushes.append('z_holdout')
+
+ ## force fake user for the brushes
+ for b in data_to.brushes:
+ b.use_fake_user = True
+
+ return len(data_to.brushes)
class GP_OT_install_brush_pack(bpy.types.Operator):
bl_idname = "gp.import_brush_pack"
- bl_label = "Import texture brush pack"
- bl_description = "import Grease Pencil brush pack from Grease Pencil addon"
+ bl_label = "Download and import texture brush pack"
+ bl_description = "Download and import Grease Pencil brush pack from the web (~3.7 Mo)"
bl_options = {"REGISTER", "INTERNAL"}
- def execute(self, context):
- from pathlib import Path
-
- blendname = 'Official_GP_brush_pack_V1.blend'
- blend_fp = Path(__file__).parent / blendname
- print('blend_fp: ', blend_fp)
-
- cur_brushes = [b.name for b in bpy.data.brushes]
- with bpy.data.libraries.load(str(blend_fp), link=False) as (data_from, data_to):
- # load brushes starting with 'tex' prefix if there are not already there
- data_to.brushes = [b for b in data_from.brushes if b.startswith('tex_') and not b in cur_brushes]
- # Add holdout
- if 'z_holdout' in data_from.brushes:
- data_to.brushes.append('z_holdout')
-
- brush_count = len(data_to.brushes)
- ## force fake user for the brushes
- for b in data_to.brushes:
- b.use_fake_user = True
-
- if brush_count:
- self.report({'INFO'}, f'{brush_count} brushes installed')
+ # @classmethod
+ # def poll(cls, context):
+ # return True
+
+ def _append_brushes(self, blend_fp):
+ bct = get_brushes(blend_fp)
+ if bct:
+ self.report({'INFO'}, f'{bct} brushes installed')
else:
self.report({'WARNING'}, 'Brushes already loaded')
+
+ def _install_from_zip(self):
+ ## get blend file name
+ blendname = None
+ with zipfile.ZipFile(self.brushzip, 'r') as zfd:
+ for f in zfd.namelist():
+ if f.endswith('.blend'):
+ blendname = f
+ break
+ if not blendname:
+ self.report({'ERROR'}, f'blend file not found in zip {self.brushzip}')
+ return
+
+ unzip(self.brushzip, self.temp)
+
+ self._append_brushes(Path(self.temp) / blendname)
+
+ def execute(self, context):
+
+ import tempfile
+ import json
+ import hashlib
+ import os
+
+ ## get temp dir
+ temp = tempfile.gettempdir()
+ if not temp:
+ self.report({'ERROR'}, 'no os temporary directory found to download brush pack (using python tempfile.gettempdir())')
+ return {"CANCELLED"}
+
+ self.temp = Path(temp)
+
+ ## download link from gitlab
+ # brush pack project https://gitlab.com/pepe-school-land/gp-brush-pack
+ repo_url = r'https://gitlab.com/api/v4/projects/21994857'
+ tree_url = f'{repo_url}/repository/tree'
+
+ ## need to create an SSl context or linux fail and raise unverified ssl
+ ssl._create_default_https_context = ssl._create_unverified_context
+
+ try:
+ with urllib.request.urlopen(tree_url) as response:
+ html = response.read()
+ except:
+ ## try loading from tempdir
+ packs = [f for f in os.listdir(self.temp) if 'GP_brush_pack' in f and f.endswith('.blend')]
+ if packs:
+ packs.sort()
+ self._append_brushes(Path(self.temp) / packs[-1])
+ self.report({'WARNING'}, 'Brushes loaded from temp directory (No download)')
+ # print('Could not reach web url : Brushes were loaded from temp directory file (No downloa
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list