def display(self, msg, modifier=None):
if not type(msg) is unicode:
# force output unicode string to output
# Python will hopefully handle output printing
msg=obj2utf8(msg)
if msg:
if modifier=="error":
self.stdout.write(PupyCmd.format_error(msg))
elif modifier=="success":
self.stdout.write(PupyCmd.format_success(msg))
elif modifier=="info":
self.stdout.write(PupyCmd.format_info(msg))
elif modifier=="srvinfo":
buf_bkp=readline.get_line_buffer()
#nG move cursor to column n
#nE move cursor ro the beginning of n lines down
#nK Erases part of the line. If n is zero (or missing), clear from cursor to the end of the line. If n is one, clear from cursor to beginning of the line. If n is two, clear entire line. Cursor position does not change.
self.stdout.write("\x1b[0G"+PupyCmd.format_srvinfo(msg)+"\x1b[0E")
self.stdout.write("\x1b[2K")#clear line
self.stdout.write(self.raw_prompt+buf_bkp)#"\x1b[2K")
try:
readline.redisplay()
except Exception:
pass
elif modifier=="warning":
self.stdout.write(PupyCmd.format_warning(msg))
else:
self.stdout.write(PupyCmd.format_log(msg))
评论列表
文章目录