[Bf-blender-cvs] [6cfd91f59e8] asset-engine: Cleanup: remove asyncio version of Amber, and Claude, from branch for now.
Bastien Montagne
noreply at git.blender.org
Wed Feb 7 10:26:53 CET 2018
Commit: 6cfd91f59e8da644bf4b1e7e2921e20e194cb54a
Author: Bastien Montagne
Date: Mon Feb 5 12:11:43 2018 +0100
Branches: asset-engine
https://developer.blender.org/rB6cfd91f59e8da644bf4b1e7e2921e20e194cb54a
Cleanup: remove asyncio version of Amber, and Claude, from branch for now.
They make review patch even more confusing, and are useless/broken
currently anyway. Claude will be redone later.
===================================================================
M release/scripts/startup/bl_operators/__init__.py
D release/scripts/startup/bl_operators/amber_asyncio.py
D release/scripts/startup/bl_operators/claude/__init__.py
D release/scripts/startup/bl_operators/claude/appdirs.py
D release/scripts/startup/bl_operators/claude/cache.py
D release/scripts/startup/bl_operators/claude/pillar.py
D release/scripts/startup/bl_operators/claude/texture_browser.py
D release/scripts/startup/bl_operators/claude/wheels/CacheControl-0.11.6-py3-none-any.whl
D release/scripts/startup/bl_operators/claude/wheels/__init__.py
D release/scripts/startup/bl_operators/claude/wheels/lockfile-0.12.2-py2.py3-none-any.whl
D release/scripts/startup/bl_operators/claude/wheels/pillarsdk-1.2.0-py2.py3-none-any.whl
D release/scripts/startup/bl_operators/claude/wheels/pillarsdk-1.4.0-py2.py3-none-any.whl
===================================================================
diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py
index b901be9d97c..1e0dbe6925e 100644
--- a/release/scripts/startup/bl_operators/__init__.py
+++ b/release/scripts/startup/bl_operators/__init__.py
@@ -50,9 +50,6 @@ _modules = [
"wm",
]
-#_modules.append("amber")
-#_modules.append("claude")
-
import bpy
if bpy.app.build_options.freestyle:
diff --git a/release/scripts/startup/bl_operators/amber_asyncio.py b/release/scripts/startup/bl_operators/amber_asyncio.py
deleted file mode 100644
index e55ef736df9..00000000000
--- a/release/scripts/startup/bl_operators/amber_asyncio.py
+++ /dev/null
@@ -1,852 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-# <pep8 compliant>
-
-# Note: This will be a simple addon later, but until it gets to master, it's simpler to have it
-# as a startup module!
-
-import bpy
-from bpy.types import (
- AssetEngine,
- Panel,
- PropertyGroup,
- UIList,
- )
-from bpy.props import (
- StringProperty,
- BoolProperty,
- IntProperty,
- FloatProperty,
- EnumProperty,
- CollectionProperty,
- )
-
-import binascii
-import concurrent.futures as futures
-import asyncio
-import hashlib
-import json
-import os
-import stat
-import struct
-import time
-import random
-
-
-AMBER_DB_NAME = "__amber_db.json"
-AMBER_DBK_VERSION = "version"
-
-
-##########
-# Helpers.
-
-# Notes about UUIDs:
-# * UUID of an asset/variant/revision is computed once at its creation! Later changes to data do not affect it.
-# * Collision, for unlikely it is, may happen across different repositories...
-# Doubt this will be practical issue though.
-# * We keep eight first bytes of 'clear' identifier, to (try to) keep some readable uuid.
-
-def _uuid_gen_single(used_uuids, uuid_root, h, str_arg):
- h.update(str_arg.encode())
- uuid = uuid_root + h.digest()
- uuid = uuid[:23].replace(b'\0', b'\1') # No null chars, RNA 'bytes' use them as in regular strings... :/
- if uuid not in used_uuids: # *Very* likely, but...
- used_uuids.add(uuid)
- return uuid
- return None
-
-
-def _uuid_gen(used_uuids, uuid_root, bytes_seed, *str_args):
- h = hashlib.md5(bytes_seed)
- for arg in str_args:
- uuid = _uuid_gen_single(used_uuids, uuid_root, h, arg)
- if uuid is not None:
- return uuid
- # This is a fallback in case we'd get a collision... Should never be needed in real life!
- for i in range(100000):
- uuid = _uuid_gen_single(used_uuids, uuid_root, h, i.to_bytes(4, 'little'))
- if uuid is not None:
- return uuid
- return None # If this happens...
-
-
-def uuid_asset_gen(used_uuids, path_db, name, tags):
- uuid_root = name.encode()[:8] + b'|'
- return _uuid_gen_single(used_uuids, uuid_root, path_db.encode(), name, *tags)
-
-
-def uuid_variant_gen(used_uuids, asset_uuid, name):
- uuid_root = name.encode()[:8] + b'|'
- return _uuid_gen_single(used_uuids, uuid_root, asset_uuid, name)
-
-
-def uuid_revision_gen(used_uuids, variant_uuid, number, size, time):
- uuid_root = str(number).encode() + b'|'
- return _uuid_gen_single(used_uuids, uuid_root, variant_uuid, str(number), str(size), str(timestamp))
-
-
-def uuid_unpack_bytes(uuid_bytes):
- return struct.unpack("!iiii", uuid_bytes.ljust(16, b'\0'))
-
-
-def uuid_unpack(uuid_hexstr):
- return uuid_unpack_bytes(binascii.unhexlify(uuid_hexstr))
-
-
-def uuid_unpack_asset(uuid_repo_hexstr, uuid_asset_hexstr):
- return uuid_unpack_bytes(binascii.unhexlify(uuid_repo_hexstr).ljust(8, b'\0') +
- binascii.unhexlify(uuid_asset_hexstr).ljust(8, b'\0'))
-
-
-def uuid_pack(uuid_iv4):
- print(uuid_iv4)
- return binascii.hexlify(struct.pack("!iiii", *uuid_iv4))
-
-
-# XXX Hack, once this becomes a real addon we'll just use addons' config system, for now store that in some own config.
-amber_repos_path = os.path.join(bpy.utils.user_resource('CONFIG', create=True), "amber_repos.json")
-amber_repos = None
-if not os.path.exists(amber_repos_path):
- with open(amber_repos_path, 'w') as ar_f:
- json.dump({}, ar_f)
-with open(amber_repos_path, 'r') as ar_f:
- amber_repos = {uuid_unpack(uuid): path for uuid, path in json.load(ar_f).items()}
-assert(amber_repos != None)
-
-
-def save_amber_repos():
- ar = {uuid_pack(uuid).decode(): path for uuid, path in amber_repos.items()}
- with open(amber_repos_path, 'w') as ar_f:
- json.dump(ar, ar_f)
-
-
-#############
-# Amber Jobs.
-class AmberJob:
- def __init__(self, job_id):
- loop = asyncio.get_event_loop()
- self.job_id = job_id
- self.job_future = loop.create_future()
- self.status = {'VALID'}
- self.progress = 0.0
-
- @staticmethod
- def async_looper(func):
- """Defines a simple wrapper around the function that executes it before stepping a bit asyncio loop."""
- def wrapper(*args, **kwargs):
- loop = asyncio.get_event_loop()
- print("proceed....")
- func(*args, **kwargs)
- print("kickstep")
- # That's the trick - since asyncio loop is not the main loop, we cannot call run_forever, or we would
- # never get back our thread (not until something in asyncio loop itself calls stop(), at least).
- # So we schedule ourselves the stop call, effectively leading to 'stepping' asyncio loop.
- # This relies on the fact that main loop (aka Blender) calls an @AmberJob.async_looper func often enough!
- loop.call_soon(loop.stop)
- loop.run_forever()
- return wrapper
-
-
-class AmberJobList(AmberJob):
- @staticmethod
- async def ls_repo(job_future, db_path):
- if job_future.cancelled():
- return None
-
- loop = asyncio.get_event_loop()
- repo = None
- with open(db_path, 'r') as db_f:
- repo = await loop.run_in_executor(None, json.load, db_f)
- if isinstance(repo, dict):
- repo_ver = repo.get(AMBER_DBK_VERSION, "")
- if repo_ver != "1.0.1":
- # Unsupported...
- print("WARNING: unsupported Amber repository version '%s'." % repo_ver)
- repo = None
- else:
- repo = None
- if repo is not None:
- # Convert hexa string to array of four uint32...
- # XXX will have to check endianess mess here, for now always use same one ('network' one).
- repo_uuid = repo["uuid"]
- repo["uuid"] = uuid_unpack(repo_uuid)
- new_entries = {}
- for euuid, e in repo["entries"].items():
- new_variants = {}
- for vuuid, v in e["variants"].items():
- new_revisions = {}
- for ruuid, r in v["revisions"].items():
- new_revisions[uuid_unpack(ruuid)] = r
- new_variants[uuid_unpack(vuuid)] = v
- v["revisions"] = new_revisions
- ruuid = v["revision_default"]
- v["revision_default"] = uuid_unpack(ruuid)
- new_entries[uuid_unpack_asset(repo_uuid, euuid)] = e
- e["variants"] = new_variants
- vuuid = e["variant_default"]
- e["variant_default"] = uuid_unpack(vuuid)
- repo["entries"] = new_entries
- #~ print(repo)
- return repo
-
- @staticmethod
- async def ls(job_future, path):
- if job_future.cancelled():
- return None
-
- print(1)
- loop = asyncio.get_event_loop()
- repo = None
- ret = [".."]
- print(2)
- tmp = await loop.run_in_executor(None, os.listdir, path)
- print(3)
- if AMBER_DB_NAME in tmp:
- # That dir is an Amber repo, we only list content define by our amber 'db'.
- repo = await AmberJobList.ls_repo(job_future, os.path.join(path, AMBER_DB_NAME))
- if repo is None:
- ret += tmp
- #~ time.sleep(0.1) # 100% Artificial Lag (c)
- print(4)
- return ret, repo
-
- @staticmethod
- async def stat(job_future, root, path):
- if job_future.cancelled():
- return None
-
- loop = asyncio.get_event_loop()
- st = await loop.run_in_executor(None, os.lstat, root + path)
- #~ time.sleep(0.1) # 100% Artificial Lag (c)
- return path, (stat.S_ISDIR(st.st_mode), st.st_size, st.st_mtime)
-
- @AmberJob.async_looper
- def start(self):
- self.nbr = 0
- self.tot = 0
- self.ls_task = asyncio.ensure_future(self.ls(self.job_future, self.root))
- self.status = {'VALID', 'RUNNING'}
-
- @AmberJob.async_looper
- def update(self, repository, dirs):
- if self.job_future.cancelled():
- self.cancel()
- return
-
- self.status = {'VALID', 'RUNNING'}
- if self.ls_task is not None:
- if not self.ls_task.done():
- return
- paths, repo = self.ls_task.result()
- self.ls_task = None
- self.tot = len(paths)
- repository.clear()
- dirs.clear()
- if repo is not None:
- repository.update(repo)
- for p in paths:
- self.stat_tasks.add(asyncio.ensure_futur
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list