[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24407] trunk/blender/release/scripts/op/ console_shell.py: use the cwd for the shell prompt, use subprocess. getstatusoutput rather then popen()
Campbell Barton
ideasman42 at gmail.com
Sun Nov 8 13:35:37 CET 2009
Revision: 24407
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24407
Author: campbellbarton
Date: 2009-11-08 13:35:37 +0100 (Sun, 08 Nov 2009)
Log Message:
-----------
use the cwd for the shell prompt, use subprocess.getstatusoutput rather then popen()
Modified Paths:
--------------
trunk/blender/release/scripts/op/console_shell.py
Modified: trunk/blender/release/scripts/op/console_shell.py
===================================================================
--- trunk/blender/release/scripts/op/console_shell.py 2009-11-08 11:33:01 UTC (rev 24406)
+++ trunk/blender/release/scripts/op/console_shell.py 2009-11-08 12:35:37 UTC (rev 24407)
@@ -18,8 +18,11 @@
# <pep8 compliant>
import sys
+import os
+
import bpy
+
language_id = 'shell'
def add_scrollback(text, text_type):
@@ -27,11 +30,18 @@
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.'''
bl_idname = "console.execute_" + language_id
@@ -64,6 +74,7 @@
bpy.ops.console.history_append(text="", current_character=0,
remove_duplicates=True)
+ sc.prompt = os.getcwd()+ShellConsoleExec.PROMPT
return ('FINISHED',)
@@ -93,7 +104,7 @@
sc = context.space_data
shell_run("bash --version")
- sc.prompt = ShellConsoleExec.PROMPT
+ sc.prompt = os.getcwd()+ShellConsoleExec.PROMPT
return ('FINISHED',)
More information about the Bf-blender-cvs
mailing list