Skip to content

Commit

Permalink
Fix command output when in shell
Browse files Browse the repository at this point in the history
  • Loading branch information
stuaxo committed May 29, 2018
1 parent e80a113 commit 06b4c48
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions shoebot/sbio/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,20 @@ def print_response(self, input='', keep=False, *args, **kwargs):
lines = input.splitlines()
if status and not lines:
lines = ['']

if cookie:
for i, line in enumerate(lines):
if i != len(lines) - 1 or keep is True:
cookie_char = '>'
else:
# last line
cookie_char = ':'

print('{cookie} {status}{cookie_char}{line}'.format(
output_template = '{cookie} {status}{cookie_char}{line}'
else:
output_template = '{line}'

for i, line in enumerate(lines):
if i != len(lines) - 1 or keep is True:
cookie_char = '>'
else:
# last line
cookie_char = ':'

print(output_template.format(
cookie_char=cookie_char,
cookie=cookie,
status=status or '',
Expand All @@ -142,8 +147,6 @@ def emptyline(self):
:return:
"""
# if not self.cookie:
# print(RESPONSE_PROMPT)
return ""

def do_escape_nl(self, arg):
Expand Down Expand Up @@ -200,7 +203,6 @@ def do_pause(self, line):
"""
Toggle pause
"""
# TODO - move this into bot controller
# along with stuff in socketserver and shell
if self.pause_speed is None:
self.pause_speed = self.bot._speed
Expand Down Expand Up @@ -271,7 +273,6 @@ def source_bad(tb):
if called_good:
# good and bad callbacks shouldn't both be called
raise ValueError('Good AND Bad callbacks called !')
# TODO - get simple_trace_back of exception to send back
self.print_response(status=RESPONSE_REVERTED, keep=True, cookie=cookie)
self.print_response(tb.replace('\n', '\\n'), cookie=cookie)
executor.clear_callbacks()
Expand Down Expand Up @@ -342,7 +343,7 @@ def do_set(self, line):
Set a variable.
"""
try:
name, sep, value = [part.strip() for part in line.split('=')]
name, value = [part.strip() for part in line.split('=')]
if name not in self.bot._vars:
self.print_response('No such variable %s enter vars to see available vars' % name)
return
Expand Down

0 comments on commit 06b4c48

Please sign in to comment.