1
0
mirror of https://github.com/JoelBender/bacpypes synced 2025-09-28 22:15:23 +08:00
This commit is contained in:
Joel Bender 2016-02-21 14:36:05 -05:00
parent ef81ce6887
commit 48342e0bec
3 changed files with 30 additions and 9 deletions

View File

@ -8,7 +8,6 @@ import sys
import types
import os
import gc
import readline
import signal
import cmd
import logging
@ -20,6 +19,12 @@ from .consolelogging import ConsoleLogHandler
from . import core
# readline is used for history files
try:
import readline
except ImportError:
readline = None
# some debugging
_debug = 0
_log = ModuleLogger(globals())
@ -263,7 +268,8 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
cmd.Cmd.preloop(self) ## sets up command completion
try:
readline.read_history_file(sys.argv[0] + ".history")
if readline:
readline.read_history_file(sys.argv[0] + ".history")
except Exception, err:
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err)
@ -273,7 +279,8 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
Despite the claims in the Cmd documentaion, Cmd.postloop() is not a stub.
"""
try:
readline.write_history_file(sys.argv[0]+".history")
if readline:
readline.write_history_file(sys.argv[0] + ".history")
except Exception, err:
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err)

View File

@ -8,7 +8,6 @@ import sys
import types
import os
import gc
import readline
import signal
import cmd
import logging
@ -20,6 +19,12 @@ from .consolelogging import ConsoleLogHandler
from . import core
# readline is used for history files
try:
import readline
except ImportError:
readline = None
# some debugging
_debug = 0
_log = ModuleLogger(globals())
@ -265,7 +270,8 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
cmd.Cmd.preloop(self) ## sets up command completion
try:
readline.read_history_file(sys.argv[0] + ".history")
if readline:
readline.read_history_file(sys.argv[0] + ".history")
except Exception as err:
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err)
@ -275,7 +281,8 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
Despite the claims in the Cmd documentaion, Cmd.postloop() is not a stub.
"""
try:
readline.write_history_file(sys.argv[0]+".history")
if readline:
readline.write_history_file(sys.argv[0] + ".history")
except Exception as err:
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err)

View File

@ -8,7 +8,6 @@ import sys
import types
import os
import gc
import readline
import signal
import cmd
import logging
@ -20,6 +19,12 @@ from .consolelogging import ConsoleLogHandler
from . import core
# readline is used for history files
try:
import readline
except ImportError:
readline = None
# some debugging
_debug = 0
_log = ModuleLogger(globals())
@ -266,7 +271,8 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
cmd.Cmd.preloop(self) ## sets up command completion
try:
readline.read_history_file(sys.argv[0] + ".history")
if readline:
readline.read_history_file(sys.argv[0] + ".history")
except Exception as err:
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err)
@ -276,7 +282,8 @@ class ConsoleCmd(cmd.Cmd, Thread, Logging):
Despite the claims in the Cmd documentaion, Cmd.postloop() is not a stub.
"""
try:
readline.write_history_file(sys.argv[0]+".history")
if readline:
readline.write_history_file(sys.argv[0] + ".history")
except Exception as err:
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err)