Update leenkx.py
This commit is contained in:
48
leenkx.py
48
leenkx.py
@ -64,45 +64,8 @@ def get_os():
|
||||
else:
|
||||
return 'linux'
|
||||
|
||||
|
||||
def detect_sdk_path():
|
||||
"""Auto-detect the SDK path after Leenkx installation."""
|
||||
preferences = bpy.context.preferences
|
||||
addon_prefs = preferences.addons["leenkx"].preferences
|
||||
|
||||
# Don't overwrite if already set
|
||||
if addon_prefs.sdk_path:
|
||||
return
|
||||
|
||||
# For all versions, try to get the path from the current file location first
|
||||
current_file = os.path.realpath(__file__)
|
||||
if os.path.exists(current_file):
|
||||
# Go up one level from the current file's directory to get the SDK root
|
||||
sdk_path = os.path.dirname(os.path.dirname(current_file))
|
||||
if os.path.exists(os.path.join(sdk_path, "leenkx")):
|
||||
addon_prefs.sdk_path = sdk_path
|
||||
return
|
||||
|
||||
# Fallback for Blender 2.92+ with the original method
|
||||
if bpy.app.version >= (2, 92, 0):
|
||||
try:
|
||||
win = bpy.context.window_manager.windows[0]
|
||||
area = win.screen.areas[0]
|
||||
area_type = area.type
|
||||
area.type = "INFO"
|
||||
|
||||
with bpy.context.temp_override(window=win, screen=win.screen, area=area):
|
||||
bpy.ops.info.select_all(action='SELECT')
|
||||
bpy.ops.info.report_copy()
|
||||
|
||||
clipboard = bpy.context.window_manager.clipboard
|
||||
match = re.findall(r"^Modules Installed .* from '(.*leenkx.py)' into",
|
||||
clipboard, re.MULTILINE)
|
||||
if match:
|
||||
addon_prefs.sdk_path = os.path.dirname(match[-1])
|
||||
finally:
|
||||
area.type = area_type
|
||||
|
||||
def detect_sdk_path22():
|
||||
"""Auto-detect the SDK path after Leenkx installation."""
|
||||
# Do not overwrite the SDK path (this method gets
|
||||
# called after each registration, not after
|
||||
@ -116,10 +79,10 @@ def detect_sdk_path22():
|
||||
area = win.screen.areas[0]
|
||||
area_type = area.type
|
||||
area.type = "INFO"
|
||||
|
||||
with bpy.context.temp_override(window=win, screen=win.screen, area=area):
|
||||
bpy.ops.info.select_all(action='SELECT')
|
||||
bpy.ops.info.report_copy()
|
||||
if bpy.app.version >= (2, 92, 0):
|
||||
with bpy.context.temp_override(window=win, screen=win.screen, area=area):
|
||||
bpy.ops.info.select_all(action='SELECT')
|
||||
bpy.ops.info.report_copy()
|
||||
area.type = area_type
|
||||
clipboard = bpy.context.window_manager.clipboard
|
||||
|
||||
@ -129,6 +92,7 @@ def detect_sdk_path22():
|
||||
if match:
|
||||
addon_prefs.sdk_path = os.path.dirname(match[-1])
|
||||
|
||||
|
||||
def get_link_web_server(self):
|
||||
return self.get('link_web_server', 'http://localhost/')
|
||||
|
||||
|
Reference in New Issue
Block a user