2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-29 12:27:40 +00:00

Fix confetty behavior when TERM not set

Particularly in non-interactive ssh, TERM is not set.
Assume empty string if TERM is not set.
This commit is contained in:
Jarrod Johnson 2017-06-27 14:04:26 -04:00
parent 86ed339b48
commit a3c06a00bf

View File

@ -143,7 +143,7 @@ def updatestatus(stateinfo={}):
info.append(time.strftime('%H:%M', time.localtime(showtime)))
if info:
status += ' [' + ','.join(info) + ']'
if os.environ['TERM'] not in ('linux'):
if os.environ.get('TERM', '') not in ('linux'):
sys.stdout.write('\x1b]0;console: %s\x07' % status)
sys.stdout.flush()
@ -175,7 +175,7 @@ def recurse_format(datum, levels=0):
def prompt():
if os.environ['TERM'] not in ('linux'):
if os.environ.get('TERM', '') not in ('linux'):
sys.stdout.write('\x1b]0;confetty: %s\x07' % target)
try:
return raw_input(target + ' -> ')
@ -337,7 +337,7 @@ def do_command(command, server):
return
argv[0] = argv[0].lower()
if argv[0] == 'exit':
if os.environ['TERM'] not in ('linux'):
if os.environ.get('TERM', '') not in ('linux'):
sys.stdout.write('\x1b]0;\x07')
sys.exit(0)
elif argv[0] in ('help', '?'):
@ -583,7 +583,7 @@ def quitconfetty(code=0, fullexit=False, fixterm=True):
# Request default color scheme, to undo potential weirdness of terminal
sys.stdout.write('\x1b[m')
if fullexit:
if os.environ['TERM'] not in ('linux'):
if os.environ.get('TERM', '') not in ('linux'):
sys.stdout.write('\x1b]0;\x07')
sys.exit(code)
else: