mirror of
https://github.com/blender/blender.git
synced 2026-01-14 03:19:40 +00:00
Rename modules in `./scripts/modules/` to use an underscore prefix to make it clear they aren't intended to be part of public API's. This also means there is no implication that these modules should be stable, allowing us to change them based on Blender's internal usage. The following modules have been marked as private: - `animsys_refactor` - `bl_console_utils` - `bl_i18n_utils` - `bl_previews_utils` - `bl_rna_utils` - `bl_text_utils` - `bl_ui_utils` - `bpy_restrict_state` - `console_python` - `console_shell` - `graphviz_export` - `keyingsets_utils` - `rna_info` - `rna_manual_reference` - `rna_xml` Note that we could further re-arrange these modules (under `_bpy_internal` in some cases), this change is mainly to mark them as private, further changes can be handed on a case-by-case basis. Ref !147773
74 lines
1.3 KiB
Python
74 lines
1.3 KiB
Python
# SPDX-FileCopyrightText: 2009-2023 Blender Authors
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
__all__ = (
|
|
"autocomplete",
|
|
"banner",
|
|
"execute",
|
|
"language_id",
|
|
)
|
|
|
|
import os
|
|
import bpy
|
|
|
|
language_id = "shell"
|
|
|
|
|
|
def add_scrollback(text, text_type):
|
|
for line in text.split("\n"):
|
|
bpy.ops.console.scrollback_append(
|
|
text=line.replace("\t", " "),
|
|
type=text_type,
|
|
)
|
|
|
|
|
|
def shell_run(text):
|
|
import subprocess
|
|
val, output = subprocess.getstatusoutput(text)
|
|
|
|
if not val:
|
|
style = 'OUTPUT'
|
|
else:
|
|
style = 'ERROR'
|
|
|
|
add_scrollback(output, style)
|
|
|
|
|
|
PROMPT = "$ "
|
|
|
|
|
|
def execute(context, _is_interactive):
|
|
sc = context.space_data
|
|
|
|
try:
|
|
line = sc.history[-1].body
|
|
except:
|
|
return {'CANCELLED'}
|
|
|
|
bpy.ops.console.scrollback_append(text=sc.prompt + line, type='INPUT')
|
|
|
|
shell_run(line)
|
|
|
|
# insert a new blank line
|
|
bpy.ops.console.history_append(text="", current_character=0,
|
|
remove_duplicates=True)
|
|
|
|
sc.prompt = os.getcwd() + PROMPT
|
|
return {'FINISHED'}
|
|
|
|
|
|
def autocomplete(_context):
|
|
# sc = context.space_data
|
|
# TODO
|
|
return {'CANCELLED'}
|
|
|
|
|
|
def banner(context):
|
|
sc = context.space_data
|
|
|
|
shell_run("bash --version")
|
|
sc.prompt = os.getcwd() + PROMPT
|
|
|
|
return {'FINISHED'}
|