console now shows unicode errors as well as errors caused by introspecting the api with autocompleate.
This commit is contained in:
@@ -85,7 +85,7 @@ def execute(context):
|
|||||||
sc = context.space_data
|
sc = context.space_data
|
||||||
|
|
||||||
try:
|
try:
|
||||||
line = sc.history[-1].line
|
line_object = sc.history[-1]
|
||||||
except:
|
except:
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
@@ -106,13 +106,22 @@ def execute(context):
|
|||||||
stdin_backup = sys.stdin
|
stdin_backup = sys.stdin
|
||||||
sys.stdin = None
|
sys.stdin = None
|
||||||
|
|
||||||
# run the console
|
# incase exception happens
|
||||||
if not line.strip():
|
line = "" # incase of encodingf error
|
||||||
line_exec = '\n' # executes a multiline statement
|
is_multiline = False
|
||||||
else:
|
|
||||||
line_exec = line
|
try:
|
||||||
|
line = line_object.line
|
||||||
|
|
||||||
|
# run the console, "\n" executes a multiline statement
|
||||||
|
line_exec = line if line.strip() else "\n"
|
||||||
|
|
||||||
is_multiline = console.push(line_exec)
|
is_multiline = console.push(line_exec)
|
||||||
|
except:
|
||||||
|
# unlikely, but this can happen with unicode errors for example.
|
||||||
|
import traceback
|
||||||
|
stderr.write(traceback.format_exc())
|
||||||
|
|
||||||
|
|
||||||
stdout.seek(0)
|
stdout.seek(0)
|
||||||
stderr.seek(0)
|
stderr.seek(0)
|
||||||
@@ -161,9 +170,6 @@ def autocomplete(context):
|
|||||||
|
|
||||||
console = get_console(hash(context.region))[0]
|
console = get_console(hash(context.region))[0]
|
||||||
|
|
||||||
current_line = sc.history[-1]
|
|
||||||
line = current_line.line
|
|
||||||
|
|
||||||
if not console:
|
if not console:
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
@@ -175,6 +181,13 @@ def autocomplete(context):
|
|||||||
stdin_backup = sys.stdin
|
stdin_backup = sys.stdin
|
||||||
sys.stdin = None
|
sys.stdin = None
|
||||||
|
|
||||||
|
scrollback = ""
|
||||||
|
scrollback_error = ""
|
||||||
|
|
||||||
|
try:
|
||||||
|
current_line = sc.history[-1]
|
||||||
|
line = current_line.line
|
||||||
|
|
||||||
# This function isnt aware of the text editor or being an operator
|
# This function isnt aware of the text editor or being an operator
|
||||||
# just does the autocomp then copy its results back
|
# just does the autocomp then copy its results back
|
||||||
current_line.line, current_line.current_character, scrollback = \
|
current_line.line, current_line.current_character, scrollback = \
|
||||||
@@ -183,6 +196,11 @@ def autocomplete(context):
|
|||||||
cursor=current_line.current_character,
|
cursor=current_line.current_character,
|
||||||
namespace=console.locals,
|
namespace=console.locals,
|
||||||
private=bpy.app.debug)
|
private=bpy.app.debug)
|
||||||
|
except:
|
||||||
|
# unlikely, but this can happen with unicode errors for example.
|
||||||
|
# or if the api attribute access its self causes an error.
|
||||||
|
import traceback
|
||||||
|
scrollback_error = traceback.format_exc()
|
||||||
|
|
||||||
# Separate automplete output by command prompts
|
# Separate automplete output by command prompts
|
||||||
if scrollback != '':
|
if scrollback != '':
|
||||||
@@ -194,6 +212,9 @@ def autocomplete(context):
|
|||||||
if scrollback:
|
if scrollback:
|
||||||
add_scrollback(scrollback, 'INFO')
|
add_scrollback(scrollback, 'INFO')
|
||||||
|
|
||||||
|
if scrollback_error:
|
||||||
|
add_scrollback(scrollback_error, 'ERROR')
|
||||||
|
|
||||||
# restore the stdin
|
# restore the stdin
|
||||||
sys.stdin = stdin_backup
|
sys.stdin = stdin_backup
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user