RTSRoot().restore() now returns the number of nonfatal errors that occurred when parsing the dict. Catch json parsing exception and print a nicer message. Signed-off-by: Andy Grover <agrover@xxxxxxxxxx> --- targetcli/ui_root.py | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/targetcli/ui_root.py b/targetcli/ui_root.py index 78ca3fe..8997f1c 100644 --- a/targetcli/ui_root.py +++ b/targetcli/ui_root.py @@ -109,9 +109,16 @@ class UIRoot(UINode): return with open(savefile, "r") as f: - RTSRoot().restore(json.loads(f.read()), clear_existing) - - self.shell.log.info("Configuration restored from %s" % savefile) + try: + errors = RTSRoot().restore(json.loads(f.read()), clear_existing) + except ValueError: + self.shell.log.error("Error parsing savefile: %s" % savefile) + return + + if errors: + self.shell.log.error("Configuration restored, %s recoverable errors" % errors) + else: + self.shell.log.info("Configuration restored from %s" % savefile) self.refresh() -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html