diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-08 15:35:37 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-08 15:35:37 +0300 |
commit | af011f33a6975d4a0176bf84027695462552e5b2 (patch) | |
tree | 3599321f3f6f8fd3075f4f7116ec62f104b24f34 /release | |
parent | 49cb4d00657ef2e81d85cddda2e6dc9f9362c7c6 (diff) |
use the cwd for the shell prompt, use subprocess.getstatusoutput rather then popen()
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/op/console_shell.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/release/scripts/op/console_shell.py b/release/scripts/op/console_shell.py index 4bf20e470e8..874101d1c79 100644 --- a/release/scripts/op/console_shell.py +++ b/release/scripts/op/console_shell.py @@ -18,8 +18,11 @@ # <pep8 compliant> import sys +import os + import bpy + language_id = 'shell' def add_scrollback(text, text_type): @@ -27,10 +30,17 @@ def add_scrollback(text, text_type): bpy.ops.console.scrollback_append(text=l.replace('\t', ' '), type=text_type) - def shell_run(text): - import os - add_scrollback(os.popen(text).read(), 'OUTPUT') + import subprocess + val, output= subprocess.getstatusoutput(text) + + if not val: + style= 'OUTPUT' + else: + style= 'ERROR' + + add_scrollback(output, style) + class ShellConsoleExec(bpy.types.Operator): '''Execute the current console line as a python expression.''' @@ -64,6 +74,7 @@ class ShellConsoleExec(bpy.types.Operator): bpy.ops.console.history_append(text="", current_character=0, remove_duplicates=True) + sc.prompt = os.getcwd()+ShellConsoleExec.PROMPT return ('FINISHED',) @@ -93,7 +104,7 @@ class ShellConsoleBanner(bpy.types.Operator): sc = context.space_data shell_run("bash --version") - sc.prompt = ShellConsoleExec.PROMPT + sc.prompt = os.getcwd()+ShellConsoleExec.PROMPT return ('FINISHED',) |