commit a221a535d718c3abbc53ee44713188d70db65a7d Author: Andy Grover Date: Tue Jun 18 10:49:50 2013 -0700 Catch module load errors If targetcli is not run for the first time not as root, refresh() will fail because it can't load modules. This returns a nicer error message in that case. See https://bugzilla.redhat.com/show_bug.cgi?id=973852 Signed-off-by: Andy Grover diff --git a/scripts/targetcli b/scripts/targetcli index a2cbff1..269dc1a 100755 --- a/scripts/targetcli +++ b/scripts/targetcli @@ -64,8 +64,11 @@ def main(): try: root_node.refresh() - except RTSLibError, error: + except Exception, error: shell.con.display(shell.con.render_text(str(error), 'red')) + if not is_root: + shell.con.display(shell.con.render_text("Retry as root.", 'red')) + sys.exit(-1) if len(sys.argv) > 1: shell.run_cmdline(" ".join(sys.argv[1:]))