Skip to content
Snippets Groups Projects
Commit 4d841d18 authored by Seblu's avatar Seblu
Browse files

update way of saving history and tagdisplay settings

parent 41093b1c
No related branches found
No related tags found
No related merge requests found
......@@ -70,7 +70,7 @@ class Cli(object):
# parsing
self._parse()
# save history
self.printer.history.write(self.settings.get("history", ""))
self.printer.history.write(self.settings.get("history", None))
def _connect(self):
'''Connect to a cloud control server'''
......
......@@ -26,7 +26,7 @@ class Command_expert(Command):
c = code.InteractiveConsole(local)
c.interact("Use Ctrl+D to go back in CLI. Type dir() to see variables.")
finally:
self.printer.history.write(self.cli.settings.get("expert", ""))
self.printer.history.write(self.cli.settings.get("expert", None))
self.printer.history.load(h)
......
......@@ -107,4 +107,7 @@ class Command_tagdisplay(OptionCommand):
del db[tagname]
else:
db[tagname] = value
self.cli.tagdisplay.save(self.cli.settings.get("tagdisplay", ""))
try:
self.cli.tagdisplay.save(self.cli.settings.get("tagdisplay", None))
except Exception as e:
raise cmdError(e)
......@@ -198,6 +198,8 @@ class History(object):
def read(self, path):
'''Load history from a file'''
self.clear()
if path is None:
return
try:
self.readline.read_history_file(path)
except IOError:
......@@ -205,6 +207,8 @@ class History(object):
def write(self, path):
'''Save history into path'''
if path is None:
return
try:
self.readline.write_history_file(path)
except IOError:
......
......@@ -26,7 +26,7 @@ class TagDisplay(object):
def load(self, filename):
'''load tagdisplay settings from file'''
if os.access(filename, os.R_OK):
if filename is not None:
fparser = ConfigParser.RawConfigParser()
fparser.read(filename)
self.__init__()
......@@ -41,7 +41,7 @@ class TagDisplay(object):
def save(self, filename):
'''save tagdisplay settings on file'''
if os.access(filename, os.R_OK or os.W_OK):
if filename is not None:
fparser = ConfigParser.RawConfigParser()
fparser.read(filename)
for n,d in (("type", self.tagtype), ("color", self.tagcolor),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment