Inconsistent behavior of bpy.utils.user_resource( ) function #62736
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#62736
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Operating system: Windows-10-10.0.17134 64 Bits
Graphics card: Quadro P4000/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 412.16
Blender Version
Broken: version: 2.80 (sub 50), branch: master, commit date: 2019-03-19 06:43, hash:
4db7842a72
Worked: unknown, 2.79 latest shows same behavior
Short description of error
As a few times before, this is in conjunction with having a custom user_scripts path via environment variables
BLENDER_USER_CONFIG
andBLENDER_USER_SCRIPTS
. When using thebpy.utils.user_resource( )
function for an own add-on, I came across something strange: Passing only the resource type (for instance'SCRIPTS'
) to it yields the correct location of my scripts. Passing the optional sub-directory suddenly defaults back to the ones inC:\Users\ME\AppData\etcetc
. See output from Blender Python console:This makes the creation of shared custom presets for my Add-on operator impossible for me, as the preset never lands on the network drive.
Exact steps for others to reproduce the error
BLENDER_USER_CONFIG
andBLENDER_USER_SCRIPTS
and assign path locations to it).bpy.utils.user_resource('SCRIPTS', 'test')
andbpy.utils.user_resource('SCRIPTS')
.Added subscriber: @RainerTrummer
The thing came up while following a given answer on StackExchange https://blender.stackexchange.com/questions/134613/can-python-operator-presets-be-shared-between-operators/134620?noredirect=1#comment231376_134620
Added subscriber: @lichtwerk
Confirmed, checking...
Added subscriber: @ideasman42
Seems to be working if the folder actually exists.
Not sure about the logic in
bpy_user_resource
/BKE_appdir_folder_id_user_notest
[responsible for falling back toget_path_user
instead ofget_path_environment
if the combined path doesnt exist...]There is also following comment there:
so it seems to be designed to leave it up to the user to create the directory first...
imo this could/should be changed -- making it consistent like the report suggests...
will look into implementing this (unless @ideasman42 has objections?)
Looking into this, from what I can tell the report is that the environment variable should take priority over the users scripts directory when neither exist.
While a reasonable suggestion this isn't a bug.
Note that creation is handled by
bpy.utils.user_resource(resource_type, path="", create=False)
.Allowing create=False is useful since you can know if the directory doesn't exist and not attempt to read it's content.
Any users of this API that want to use the first scripts path found (environment var) can use
os.path.join(bpy.utils.user_resource('SCRIPTS'), 'test')
.Setting as TODO.
@ideasman42 : thing is that even if the directory specified in
BLENDER_USER_CONFIG
environment variable exists, it will fallback toget_path_user
if the specified subfolder doesnt exist.(this is because
BKE_appdir_folder_id_user_notest
does indeed test if the directory exists indirectly, so calling it_notest
is pretty much nonsense...)@ideasman42
bpy.utils.user_resource(resource_type, path="", create=False)
is indeed useful. The bug report however tackles a case which is buried within theAddPresetBase
class. There,bpy.utils.user_resource(resource_type, path="somesubpath", create=**True**)
is called. The subpath IS then created as it should be, but not within the path coming fromget_path_environment
. The location it ends up in is unexpected and undesired from a user's side.This issue was referenced by
fe7c7d2820
Changed status from 'Open' to: 'Resolved'