1
0
mirror of https://github.com/JoelBender/bacpypes synced 2025-09-28 22:15:23 +08:00

check to see if the application is running interactively (using isatty) and be a little quieter

This commit is contained in:
Joel Bender 2016-01-28 14:13:28 -05:00
parent df21d273ab
commit f4afe0ce19
3 changed files with 48 additions and 12 deletions

View File

@ -44,8 +44,16 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
cmd.Cmd.__init__(self, stdin=stdin, stdout=stdout)
Thread.__init__(self, name="ConsoleCmd")
# save the prompt and exec option
# check to see if this is running interactive
self.interactive = sys.__stdin__.isatty()
# save the prompt for interactive sessions, otherwise be quiet
if self.interactive:
self.prompt = prompt
else:
self.prompt = ''
# save the exec option
self.allow_exec = allow_exec
# gc counters
@ -272,9 +280,13 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err)
cmd.Cmd.postloop(self) ## Clean up command completion
# clean up command completion
cmd.Cmd.postloop(self)
if self.interactive:
self.stdout.write("Exiting...\n")
# tell the core we have stopped
core.stop()
def precmd(self, line):

View File

@ -45,8 +45,16 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
cmd.Cmd.__init__(self, stdin=stdin, stdout=stdout)
Thread.__init__(self, name="ConsoleCmd")
# save the prompt and exec option
# check to see if this is running interactive
self.interactive = sys.__stdin__.isatty()
# save the prompt for interactive sessions, otherwise be quiet
if self.interactive:
self.prompt = prompt
else:
self.prompt = ''
# save the exec option
self.allow_exec = allow_exec
# gc counters
@ -273,9 +281,13 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err)
cmd.Cmd.postloop(self) ## Clean up command completion
# clean up command completion
cmd.Cmd.postloop(self)
if self.interactive:
self.stdout.write("Exiting...\n")
# tell the core we have stopped
core.stop()
def precmd(self, line):

View File

@ -45,8 +45,16 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
cmd.Cmd.__init__(self, stdin=stdin, stdout=stdout)
Thread.__init__(self, name="ConsoleCmd")
# save the prompt and exec option
# check to see if this is running interactive
self.interactive = sys.__stdin__.isatty()
# save the prompt for interactive sessions, otherwise be quiet
if self.interactive:
self.prompt = prompt
else:
self.prompt = ''
# save the exec option
self.allow_exec = allow_exec
# gc counters
@ -274,9 +282,13 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err)
cmd.Cmd.postloop(self) ## Clean up command completion
# clean up command completion
cmd.Cmd.postloop(self)
if self.interactive:
self.stdout.write("Exiting...\n")
# tell the core we have stopped
core.stop()
def precmd(self, line):